]> git.lizzy.rs Git - rust.git/commitdiff
Add note about clone in docs for vec![]
authorManish Goregaokar <manishsmail@gmail.com>
Sun, 6 Sep 2015 14:57:37 +0000 (20:27 +0530)
committerManish Goregaokar <manishsmail@gmail.com>
Sun, 6 Sep 2015 22:27:20 +0000 (03:57 +0530)
src/libcollections/macros.rs

index 5f614f3649ca9fd93f08765b44c46df3002a49ec..6a683e65c9eb302237d41743bc6f0a84737cbca7 100644 (file)
 /// Note that unlike array expressions this syntax supports all elements
 /// which implement `Clone` and the number of elements doesn't have to be
 /// a constant.
+///
+/// This will use `clone()` to duplicate an expression, so one should be careful
+/// using this with types having a nonstandard `Clone` implementation. For
+/// example, `vec![Rc::new(1); 5]` will create a vector of five references
+/// to the same boxed integer value, not five references pointing to independently
+/// boxed integers.
 #[cfg(not(test))]
 #[macro_export]
 #[stable(feature = "rust1", since = "1.0.0")]