diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-10-17 13:46:12 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-17 13:46:12 +0200 |
| commit | 5bf5d6dc73ada7628a5ea91a9905b5c5ef15b46e (patch) | |
| tree | cefebe2c6f3b3babf2ba200807b44069f8d242ec | |
| parent | accc6e7e4aea2ca6482d27766e89549a4890e07a (diff) | |
| parent | 940d48ed6021541d5e9576873982f68967d4ec87 (diff) | |
| download | rust-5bf5d6dc73ada7628a5ea91a9905b5c5ef15b46e.tar.gz rust-5bf5d6dc73ada7628a5ea91a9905b5c5ef15b46e.zip | |
Rollup merge of #65475 - lzutao:eg_type_name, r=Centril
add example for type_name So users of this function could at least expect what its output for current compiler version.
| -rw-r--r-- | src/libcore/any.rs | 9 |
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 { |
