Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Struct {}
- trait Trait {
- type S;
- const S:usize;
- }
- impl Trait for Struct {
- type S = i32;
- const S:usize = std::mem::size_of::<Struct>();
- }
- /*
- fn i_from_slice<T:Trait>(slice: &[u8]) -> Option<T>
- {
- match slice.len() {
- T::S => {
- let mut buf = [0; T::S];
- buf.copy_from_slice(slice);
- Some(unsafe { std::mem::transmute_copy(&buf) })
- }
- _ => None,
- }
- }
- */
- fn main() {
- println!("Hello, world!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement