Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Bar<'a> {
- c: &'a [u8],
- }
- impl<'a> Bar<'a> {
- fn new(c: &'a [u8]) -> Bar<'a> {
- Bar { c }
- }
- }
- struct Foo<'a> {
- a: &'a [u8],
- b: Bar<'a>,
- }
- impl<'a> Foo<'a> {
- fn new(a: &'a [u8]) -> Foo<'a> {
- let mut b = a.to_vec();
- b.push(4);
- Foo { a, b: Bar::new(&b) }
- }
- }
- fn main() {
- let foo = Foo::new(&[1, 2, 3]);
- println!("{:x?} {:x?}", foo.a, foo.b.c);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement