Skip to content

Commit

Permalink
Rollup merge of rust-lang#65475 - lzutao:eg_type_name, r=Centril
Browse files Browse the repository at this point in the history
add example for type_name

So users of this function could at least expect what its output for current compiler version.
  • Loading branch information
Centril authored Oct 16, 2019
2 parents 028c586 + 940d48e commit 8ecdc84
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/libcore/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,15 @@ impl TypeId {
///
/// The current implementation uses the same infrastructure as compiler
/// diagnostics and debuginfo, but this is not guaranteed.
///
/// # Example
///
/// ```rust
/// assert_eq!(
/// std::any::type_name::<Option<String>>(),
/// "core::option::Option<alloc::string::String>",
/// );
/// ```
#[stable(feature = "type_name", since = "1.38.0")]
#[rustc_const_unstable(feature = "const_type_name")]
pub const fn type_name<T: ?Sized>() -> &'static str {
Expand Down

0 comments on commit 8ecdc84

Please sign in to comment.