2 Checks for reference-counted pointers (`Arc`, `Rc`, `rc::Weak`, and `sync::Weak`)
6 This will create `elem` once and clone it `len` times - doing so with `Arc`/`Rc`/`Weak`
7 is a bit misleading, as it will create references to the same pointer, rather
8 than different instances.
12 let v = vec![std::sync::Arc::new("some data".to_string()); 100];
14 let v = vec![std::rc::Rc::new("some data".to_string()); 100];
18 // Initialize each value separately:
19 let mut data = Vec::with_capacity(100);
21 data.push(std::rc::Rc::new("some data".to_string()));
24 // Or if you want clones of the same reference,
25 // Create the reference beforehand to clarify that
26 // it should be cloned for each value
27 let data = std::rc::Rc::new("some data".to_string());
28 let v = vec![data; 100];