Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::collections::HashMap;
- #[derive(Debug)]
- struct Child(String);
- #[derive(Debug)]
- struct Parent<'a> {
- s: HashMap<String, &'a Child>
- }
- impl<'a> Parent<'a> {
- fn new() -> Parent<'a> {
- Parent {
- s: HashMap::new()
- }
- }
- fn s_mut(&mut self) -> &mut HashMap<String, &'a Child> {
- &mut self.s
- }
- }
- fn main() {
- let c = Child("a".to_string());
- let mut p = Parent::new();
- p.s_mut().insert("k".to_string(), &c);
- println!("{:?}", p);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement