From 5e2d8545e8f470a9b25f54e84d93e808e17d73e4 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sun, 6 Sep 2015 20:27:37 +0530 Subject: [PATCH] Add note about clone in docs for vec![] --- src/libcollections/macros.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libcollections/macros.rs b/src/libcollections/macros.rs index 5f614f3649ca9..6a683e65c9eb3 100644 --- a/src/libcollections/macros.rs +++ b/src/libcollections/macros.rs @@ -32,6 +32,12 @@ /// 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")]