mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
improve doc
This commit is contained in:
parent
8a09420ac4
commit
f9490c8121
@ -1070,7 +1070,8 @@ impl<T, A: Allocator> Vec<T, A> {
|
||||
|
||||
/// Converts the vector into [`Box<[T]>`][owned slice].
|
||||
///
|
||||
/// Note that this will drop any excess capacity.
|
||||
/// If the vector has excess capacity, its items will be moved into a
|
||||
/// newly-allocated buffer with exactly the right capacity.
|
||||
///
|
||||
/// [owned slice]: Box
|
||||
///
|
||||
@ -3223,6 +3224,14 @@ impl<T, A: Allocator> From<Vec<T, A>> for Box<[T], A> {
|
||||
/// ```
|
||||
/// assert_eq!(Box::from(vec![1, 2, 3]), vec![1, 2, 3].into_boxed_slice());
|
||||
/// ```
|
||||
///
|
||||
/// Any excess capacity is removed:
|
||||
/// ```
|
||||
/// let mut vec = Vec::with_capacity(10);
|
||||
/// vec.extend([1, 2, 3]);
|
||||
///
|
||||
/// assert_eq!(Box::from(vec), vec![1, 2, 3].into_boxed_slice());
|
||||
/// ```
|
||||
fn from(v: Vec<T, A>) -> Self {
|
||||
v.into_boxed_slice()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user