about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorLzu Tao <taolzu@gmail.com>2019-10-16 16:50:07 +0000
committerLzu Tao <taolzu@gmail.com>2019-10-16 16:54:04 +0000
commit940d48ed6021541d5e9576873982f68967d4ec87 (patch)
treec2b69ffcca19401e07aa624c9c42cf4697d0277c /src
parent53aca553ec08e62a0591806fcf0f706ee9f53778 (diff)
downloadrust-940d48ed6021541d5e9576873982f68967d4ec87.tar.gz
rust-940d48ed6021541d5e9576873982f68967d4ec87.zip
add example for type_name
Diffstat (limited to 'src')
-rw-r--r--src/libcore/any.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libcore/any.rs b/src/libcore/any.rs
index f75b7a45443..e2704e807d1 100644
--- a/src/libcore/any.rs
+++ b/src/libcore/any.rs
@@ -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 {