add array from_ref
This commit is contained in:
parent
e0bc267512
commit
179f63dafc
3 changed files with 31 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
|||
use core::array::{FixedSizeArray, IntoIter};
|
||||
use core::array::{self, FixedSizeArray, IntoIter};
|
||||
use core::convert::TryFrom;
|
||||
|
||||
#[test]
|
||||
|
@ -19,6 +19,21 @@ fn fixed_size_array() {
|
|||
assert_eq!(FixedSizeArray::as_mut_slice(&mut empty_zero_sized).len(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn array_from_ref() {
|
||||
let value: String = "Hello World!".into();
|
||||
let arr: &[String; 1] = array::from_ref(&value);
|
||||
assert_eq!(&[value.clone()], arr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn array_from_mut() {
|
||||
let mut value: String = "Hello World".into();
|
||||
let arr: &mut [String; 1] = array::from_mut(&mut value);
|
||||
arr[0].push_str("!");
|
||||
assert_eq!(&value, "Hello World!");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn array_try_from() {
|
||||
macro_rules! test {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue