Skip to content

Commit 5bf5d6d

Browse files
authored
Rollup merge of rust-lang#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.
2 parents accc6e7 + 940d48e commit 5bf5d6d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Diff for: src/libcore/any.rs

+9
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,15 @@ impl TypeId {
445445
///
446446
/// The current implementation uses the same infrastructure as compiler
447447
/// diagnostics and debuginfo, but this is not guaranteed.
448+
///
449+
/// # Example
450+
///
451+
/// ```rust
452+
/// assert_eq!(
453+
/// std::any::type_name::<Option<String>>(),
454+
/// "core::option::Option<alloc::string::String>",
455+
/// );
456+
/// ```
448457
#[stable(feature = "type_name", since = "1.38.0")]
449458
#[rustc_const_unstable(feature = "const_type_name")]
450459
pub const fn type_name<T: ?Sized>() -> &'static str {

0 commit comments

Comments
 (0)