Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita6b22e9

Browse files
authored
Rollup merge ofrust-lang#127134 - tgross35:typeid-debug, r=Nilstrieb
Print `TypeId` as a `u128` for `Debug`Since <rust-lang#121358>, `TypeId` is represented as a `(u64, u64)`. This also made the debug implementation a lot larger, which is especially apparent with pretty formatting.Change this to convert the inner value back to a `u128` and then print as a tuple struct to make this less noisy.Current: TypeId { t: (1403077013027291752, 4518903163082958039) } TypeId { t: ( 1403077013027291752, 4518903163082958039, ), }New: TypeId(25882202575019293479932656973818029271) TypeId( 25882202575019293479932656973818029271, )
2 parents7f0bb45 +affa2f9 commita6b22e9

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

‎core/src/any.rs‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ impl dyn Any + Send + Sync {
602602
/// While `TypeId` implements `Hash`, `PartialOrd`, and `Ord`, it is worth
603603
/// noting that the hashes and ordering will vary between Rust releases. Beware
604604
/// of relying on them inside of your code!
605-
#[derive(Clone,Copy,Debug,Eq,PartialOrd,Ord)]
605+
#[derive(Clone,Copy,Eq,PartialOrd,Ord)]
606606
#[stable(feature ="rust1", since ="1.0.0")]
607607
pubstructTypeId{
608608
// We avoid using `u128` because that imposes higher alignment requirements on many platforms.
@@ -644,6 +644,10 @@ impl TypeId {
644644
let t2 = tasu64;
645645
TypeId{t:(t1, t2)}
646646
}
647+
648+
fnas_u128(self) ->u128{
649+
u128::from(self.t.0) <<64 | u128::from(self.t.1)
650+
}
647651
}
648652

649653
#[stable(feature ="rust1", since ="1.0.0")]
@@ -666,6 +670,13 @@ impl hash::Hash for TypeId {
666670
}
667671
}
668672

673+
#[stable(feature ="rust1", since ="1.0.0")]
674+
impl fmt::DebugforTypeId{
675+
fnfmt(&self,f:&mut fmt::Formatter<'_>) ->Result<(), fmt::Error>{
676+
f.debug_tuple("TypeId").field(&self.as_u128()).finish()
677+
}
678+
}
679+
669680
/// Returns the name of a type as a string slice.
670681
///
671682
/// # Note

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp