about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAmit Aryeh Levy <amit@amitlevy.com>2015-09-23 11:38:01 -0400
committerAmit Aryeh Levy <amit@amitlevy.com>2015-09-23 11:38:01 -0400
commitb30d8969e86fa2c9dd3b8e2e28ddda2202331f0f (patch)
tree4e96af004db4ef6f2e6979deec7cee1ffe288a0c
parent85f48d300a1161338e14b9579007b003c48dc4ba (diff)
downloadrust-b30d8969e86fa2c9dd3b8e2e28ddda2202331f0f.tar.gz
rust-b30d8969e86fa2c9dd3b8e2e28ddda2202331f0f.zip
Explain in comment why FixedSizeArray is unsafe
-rw-r--r--src/libcore/array.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libcore/array.rs b/src/libcore/array.rs
index 976689beccd..c986914440d 100644
--- a/src/libcore/array.rs
+++ b/src/libcore/array.rs
@@ -35,6 +35,15 @@ use slice::{Iter, IterMut, SliceExt};
 ///
 /// This trait can be used to implement other traits on fixed-size arrays
 /// without causing much metadata bloat.
+///
+/// The trait is marked unsafe in order to restrict implementors to fixed-size
+/// arrays. User of this trait can assume that implementors have the exact
+/// layout in memory of a fixed size array (for example, for unsafe
+/// initialization).
+///
+/// Note that the traits AsRef and AsMut provide similar methods for types that
+/// may not be fixed-size arrays. Implementors should prefer those traits
+/// instead.
 pub unsafe trait FixedSizeArray<T> {
     /// Converts the array to immutable slice
     fn as_slice(&self) -> &[T];