Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created May 9, 2019 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/4ea94f766d49abdbc9b2c55e49a9d2d9 to your computer and use it in GitHub Desktop.
Save rust-play/4ea94f766d49abdbc9b2c55e49a9d2d9 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
#![feature(optin_builtin_traits)]
trait Encode {
fn encode() -> Vec<u8>;
}
auto trait GeneralVecEncode {}
impl !GeneralVecEncode for u8 {}
impl Encode for u8 {
fn encode() -> Vec<u8> { vec![0x2; 1] }
}
impl<T> Encode for Vec<T>
where
T: Encode + GeneralVecEncode
{
fn encode() -> Vec<u8> { vec![0x0; 1] }
}
impl Encode for Vec<u8> {
fn encode() -> Vec<u8> { vec![0x1; 1] }
}
fn main() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment