File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -1660,15 +1660,25 @@ pub struct PointeeInfo {
16601660
16611661impl LayoutS {
16621662 /// Returns `true` if the layout corresponds to an unsized type.
1663+ #[ inline]
16631664 pub fn is_unsized ( & self ) -> bool {
16641665 self . abi . is_unsized ( )
16651666 }
16661667
1668+ #[ inline]
16671669 pub fn is_sized ( & self ) -> bool {
16681670 self . abi . is_sized ( )
16691671 }
16701672
1673+ /// Returns `true` if the type is sized and a 1-ZST (meaning it has size 0 and alignment 1).
1674+ pub fn is_1zst ( & self ) -> bool {
1675+ self . is_sized ( ) && self . size . bytes ( ) == 0 && self . align . abi . bytes ( ) == 1
1676+ }
1677+
16711678 /// Returns `true` if the type is a ZST and not unsized.
1679+ ///
1680+ /// Note that this does *not* imply that the type is irrelevant for layout! It can still have
1681+ /// non-trivial alignment constraints. You probably want to use `is_1zst` instead.
16721682 pub fn is_zst ( & self ) -> bool {
16731683 match self . abi {
16741684 Abi :: Scalar ( _) | Abi :: ScalarPair ( ..) | Abi :: Vector { .. } => false ,
You can’t perform that action at this time.
0 commit comments