Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. fn test<T: AsRef<[u8]> + 'static>(v: T) {
  2. let r: &[u8] = v.as_ref();
  3. println!("{:?}", r);
  4. }
  5.  
  6.  
  7. fn main() {
  8.  
  9. let vec: Vec<u8> = vec![1, 2, 3, 4];
  10. test(vec);
  11.  
  12. let arr_ref: &[u8] = &[5, 6, 7, 8];
  13. test(arr_ref);
  14.  
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement