Advertisement
Guest User

Untitled

a guest
May 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. struct Bar<'a> {
  2. c: &'a [u8],
  3. }
  4.  
  5. impl<'a> Bar<'a> {
  6. fn new(c: &'a [u8]) -> Bar<'a> {
  7. Bar { c }
  8. }
  9. }
  10.  
  11. struct Foo<'a> {
  12. a: &'a [u8],
  13. b: Bar<'a>,
  14. }
  15.  
  16. impl<'a> Foo<'a> {
  17. fn new(a: &'a [u8]) -> Foo<'a> {
  18. let mut b = a.to_vec();
  19. b.push(4);
  20. Foo { a, b: Bar::new(&b) }
  21. }
  22. }
  23.  
  24. fn main() {
  25. let foo = Foo::new(&[1, 2, 3]);
  26. println!("{:x?} {:x?}", foo.a, foo.b.c);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement