-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add example to Any documentation #15483
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
Conversation
//! `&mut Any`, there is also the `as_mut` method, for getting a mutable reference to the inner | ||
//! value. `Box<Any>` adds the `move` method, which will unwrap a `Box<T>` from the object. See | ||
//! the extension traits (`*Ext`) for the full details. | ||
/*! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convention is to use //!
OK, I decided to just go with the simple match example in the end. Appreciate it if you could check the accuracy of my claim regarding Any and traits - I think it's correct, but I wouldn't want to lead people astray :-) |
//! // different type: just print it out unadorned. | ||
//! match value_any.as_ref::<String>() { | ||
//! Some(as_string) => { | ||
//! println!("String ({}): {}", as_string.len(), as_string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I broke the match onto separate lines like this to stay within the 80 character doc limit. Seems a bit less standard, though - any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the limit is no longer 80 but back to 100, or rather 99 (rust-lang/rust-guidelines#12).
Could you squash the two commits together as well? Other than that this looks good to go! |
Done! |
Noticed there wasn't an awful lot of info out there on using Any types, so added an example to the rustdocs.
…eykril internal: post-bump lsp-server version
Noticed there wasn't an awful lot of info out there on using Any types, so added an example to the rustdocs.