Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display implementation ignores formatting paramters #43

Open
wainwrightmark opened this issue Feb 23, 2024 · 0 comments
Open

Display implementation ignores formatting paramters #43

wainwrightmark opened this issue Feb 23, 2024 · 0 comments

Comments

@wainwrightmark
Copy link

Hi. I'm not sure if this is intentional or not but the Display implementation ignores all formatting parameters

println!("ab{:>2}", "c"); //prints "ab c"
println!("ab{:>2}", Ustr::from_str("c").unwrap()); //prints "abc"

I believe this could be resolved by changing the current implementation to something like

impl fmt::Display for Ustr {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
       self.as_str().fmt(f)
    }
}

Obviously this would be a breaking change but possibly not a serious one as using formatting parameters currently does nothing, so it seems unlikely that anybody would be relying on the current behaviour.

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

No branches or pull requests

1 participant