Created
April 30, 2024 12:57
-
-
Save mizchi/d3ab781110814b6b46152c64ec4ad8b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Serializer { | |
serialize(Self) -> Bytes | |
} | |
impl Serializer for Int with serialize(self) { | |
Bytes::from_array([ | |
self.land(0xFF), | |
self.lsr(8).land(0xFF), | |
self.lsr(16).land(0xFF), | |
self.lsr(24).land(0xFF) | |
]) | |
} | |
fn main { | |
let bytes = (1 as Serializer).serialize() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment