Skip to content

feat: impl Display for FilterType#3071

Open
Its-Just-Nans wants to merge 3 commits into
image-rs:mainfrom
Its-Just-Nans:impl-display
Open

feat: impl Display for FilterType#3071
Its-Just-Nans wants to merge 3 commits into
image-rs:mainfrom
Its-Just-Nans:impl-display

Conversation

@Its-Just-Nans

Copy link
Copy Markdown
Contributor

Hello

What do you think about impl display for FilterType ?

@RunDevelopment

Copy link
Copy Markdown
Member

What's the motivation for this?

As is, this implementation of Display behaves the same as the derived Debug-printing with {:?}.

@Its-Just-Nans

Copy link
Copy Markdown
Contributor Author

What's the motivation for this?

As is, this implementation of Display behaves the same as the derived Debug-printing with {:?}.

Yes, it will be the same but it will use the Display Trait instead of the Debug which is more correct in case of printing it

@RunDevelopment

Copy link
Copy Markdown
Member

which is more correct in case of printing it

What do you mean by "correct"? Could you please explain when and why the Display trait should be preferred over the Debug trait.

@Its-Just-Nans

Copy link
Copy Markdown
Contributor Author

which is more correct in case of printing it

What do you mean by "correct"? Could you please explain when and why the Display trait should be preferred over the Debug trait.

Debug is for developers and Display for end user. Therefore I prefer to use Display

@RunDevelopment

Copy link
Copy Markdown
Member

Debug is for developers and Display for end user.

That much the documentation of those traits says...

I'm asking why you chose Display here. I'm still asking for motivation, because you still haven't given any. I don't see any upsides to having a redundant Display impl, so what do you see that I don't?

Comment thread src/imageops/sample.rs Outdated
match self {
FilterType::Nearest => write!(f, "Nearest"),
FilterType::Triangle => write!(f, "Triangle"),
FilterType::CatmullRom => write!(f, "CatmullRom"),

@197g 197g Jul 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's different requirements here, end-User display implementations should prefer plain english and avoid code formatting. We might certainly consider if Display is applicable but making it work like Debug is not going to happen as I find that simply misleading. Since I can't really convince myself of any particular capitalization, I'm afraid that FilterType has too narrow a scope for implementing Display.

The OsString::display() method demonstrates another alternative to be considered (not done, considered!). Maybe there's context in which all the above ambiguity is resolved and an expected (english) representation exists?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I've edited the MR, feel free to close it if needed

@Its-Just-Nans
Its-Just-Nans requested a review from 197g July 17, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants