diff options
Diffstat (limited to 'compiler/rustc_metadata/src/rmeta/table.rs')
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/table.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/table.rs b/compiler/rustc_metadata/src/rmeta/table.rs index 7a23cba536a..53fc2efe00b 100644 --- a/compiler/rustc_metadata/src/rmeta/table.rs +++ b/compiler/rustc_metadata/src/rmeta/table.rs @@ -186,6 +186,20 @@ impl FixedSizeEncoding for Option<RawDefId> { } } +impl FixedSizeEncoding for Option<()> { + type ByteArray = [u8; 1]; + + #[inline] + fn from_bytes(b: &[u8; 1]) -> Self { + (b[0] != 0).then(|| ()) + } + + #[inline] + fn write_to_bytes(self, b: &mut [u8; 1]) { + b[0] = self.is_some() as u8 + } +} + // NOTE(eddyb) there could be an impl for `usize`, which would enable a more // generic `Lazy<T>` impl, but in the general case we might not need / want to // fit every `usize` in `u32`. |
