From 940d48ed6021541d5e9576873982f68967d4ec87 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 16 Oct 2019 16:50:07 +0000 Subject: [PATCH] add example for type_name --- src/libcore/any.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libcore/any.rs b/src/libcore/any.rs index f75b7a4544384..e2704e807d104 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::>(), +/// "core::option::Option", +/// ); +/// ``` #[stable(feature = "type_name", since = "1.38.0")] #[rustc_const_unstable(feature = "const_type_name")] pub const fn type_name() -> &'static str {