Skip to content

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

Closed
wants to merge 1 commit into from
Closed

Add example to Any documentation #15483

wants to merge 1 commit into from

Conversation

AlisdairO
Copy link
Contributor

Noticed there wasn't an awful lot of info out there on using Any types, so added an example to the rustdocs.

//! `&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.
/*!
Copy link
Member

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 //!

@AlisdairO
Copy link
Contributor Author

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);
Copy link
Contributor Author

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?

Copy link
Member

Choose a reason for hiding this comment

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

Looks good to me!

Copy link
Member

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).

@alexcrichton
Copy link
Member

Could you squash the two commits together as well? Other than that this looks good to go!

@AlisdairO
Copy link
Contributor Author

Done!

bors added a commit that referenced this pull request Jul 9, 2014
Noticed there wasn't an awful lot of info out there on using Any types, so added an example to the rustdocs.
@bors bors closed this Jul 9, 2014
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 21, 2023
…eykril

internal: post-bump lsp-server version
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.

5 participants