diff --git a/src/lib.rs b/src/lib.rs index a7e5a36..08c452c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,7 +22,12 @@ pub fn write(wr: W, value: V) -> io::Result { value.write(wr) } -pub trait Integer { +// Seal to prevent downstream implementations of the Integer trait. +mod private { + pub trait Sealed {} +} + +pub trait Integer: private::Sealed { fn write(self, W) -> io::Result; } @@ -51,6 +56,8 @@ macro_rules! impl_IntegerCommon { Ok(bytes.len()) } } + + impl private::Sealed for $t {} }; }