We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
#[deriving(ToStr)]
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
#[deriving(ToStr)] struct Foo<A>(A); struct Bar; impl ToStr for Bar { fn to_str(&self) -> ~str { ~"some string" } } fn main() { println(Bar.to_str()); println(Foo(Bar).to_str()); }
prints:
some string {__field__: {}}
Ignoring the strange struct printing, it should probably print:
some string {__field__: some string}
i.e. use the ToStr impl of any generics.
ToStr
The text was updated successfully, but these errors were encountered:
Edit: disregard all this, I'm working on a fix
This may also be a problem with fmt!. With deriving(ToStr), you can pass rustc --pretty expanded to get what it expands to:
fmt!
deriving(ToStr)
--pretty expanded
#[deriving(ToStr)] struct Foo<A>(A); #[doc = "Automatically derived."] pub impl <A: ::std::to_str::ToStr> ::std::to_str::ToStr for Foo<A> { pub fn to_str(&self) -> ~str { match *self { Foo(ref __self_0_0) => ::std::sys::log_str(&*self) } } }
Which is basically invoking fmt("%?", self). And, as expected, the program
fmt("%?", self)
#[deriving(ToStr)] struct Foo<A>(A); struct Bar; impl ToStr for Bar { fn to_str(&self) -> ~str { ~"some string" } } fn main() { println(Bar.to_str()); println(Foo(Bar).to_str()); println(fmt!("%?", Foo(Bar))); }
also prints out
some string {__field__: {}} {__field__: {}}
Sorry, something went wrong.
fc83d82
Auto merge of rust-lang#7180 - flip1995:changelog, r=camsteffen
f3a0ac1
Update CHANGELOG.md This changelog is **big**. 🎉 [Rendered](https://github.com/flip1995/rust-clippy/blob/changelog/CHANGELOG.md) changelog: none
Successfully merging a pull request may close this issue.
prints:
Ignoring the strange struct printing, it should probably print:
i.e. use the
ToStr
impl of any generics.The text was updated successfully, but these errors were encountered: