Created
May 9, 2019 08:07
-
-
Save rust-play/4ea94f766d49abdbc9b2c55e49a9d2d9 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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
#![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