Skip to content

Instantly share code, notes, and snippets.

Created March 12, 2016 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/cc09dc0747bd11da9205 to your computer and use it in GitHub Desktop.
Save anonymous/cc09dc0747bd11da9205 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
use std::rc::{Rc, Weak};
fn main() {
let mut col = Collection::<String>::new();
col.push("12345".to_string());
}
struct Collection<'a, T: 'a> {
items: Vec<Weak<CollectionItem<'a, T>>>
}
struct CollectionItem<'a, T: 'a> {
owner: &'a Collection<'a, T>,
value: T
}
impl<'a, T: 'a> Collection<'a, T> {
fn new() -> Self {
Collection {
items: Vec::new()
}
}
fn push(&'a mut self, value: T) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment