pub struct Array<T, const LEN: usize, const REVERSE_STR: bool = false>(/* private fields */);
Expand description
Wrapper type for all fixed arrays implementing many important traits, so types based on it can simply derive their implementations.
Type keeps data in little-endian byte order and displays them in the same order (like bitcoin SHA256 single hash type).
Implementations§
source§impl<T, const LEN: usize, const REVERSE_STR: bool> Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> Array<T, LEN, REVERSE_STR>
sourcepub fn with_fill(val: T) -> Selfwhere
T: Copy,
pub fn with_fill(val: T) -> Selfwhere
T: Copy,
Constructs array filled with given value.
TODO: Revert commit 7110cee0cf539d8ff4270450183f7060a585bc87 and make
method const
once const_fn_trait_bound
stabilize
sourcepub const fn from_array(inner: [T; LEN]) -> Self
pub const fn from_array(inner: [T; LEN]) -> Self
Wraps inner representation into array type.
sourcepub fn as_slice_mut(&mut self) -> &mut [T]
pub fn as_slice_mut(&mut self) -> &mut [T]
Returns mutable byte slice representation.
source§impl<const LEN: usize, const REVERSE_STR: bool> Array<u8, LEN, REVERSE_STR>
impl<const LEN: usize, const REVERSE_STR: bool> Array<u8, LEN, REVERSE_STR>
sourcepub fn from_slice_unsafe(slice: impl AsRef<[u8]>) -> Self
pub fn from_slice_unsafe(slice: impl AsRef<[u8]>) -> Self
Constructs a byte array from the slice. Expects the slice length
doesn’t match LEN
constant generic.
§Safety
Panics if the slice length doesn’t match LEN
constant generic.
sourcepub fn to_byte_array(&self) -> [u8; LEN]
pub fn to_byte_array(&self) -> [u8; LEN]
Returns a byte array representation stored in the wrapped type.
source§impl<T, const LEN: usize, const REVERSE_STR: bool> Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> Array<T, LEN, REVERSE_STR>
sourcepub fn from_slice(slice: impl AsRef<[T]>) -> Option<Self>
👎Deprecated since 4.2.0: use copy_from_slice
pub fn from_slice(slice: impl AsRef<[T]>) -> Option<Self>
Constructs 256-bit array from a provided slice. If the slice length
is not equal to LEN
bytes, returns None
sourcepub fn copy_from_slice(slice: impl AsRef<[T]>) -> Result<Self, FromSliceError>
pub fn copy_from_slice(slice: impl AsRef<[T]>) -> Result<Self, FromSliceError>
Constructs 256-bit array by copying from a provided slice. Errors if the
slice length is not equal to LEN
bytes.
Trait Implementations§
source§impl<const LEN: usize, const REVERSE_STR: bool> BitAndAssign for Array<u8, LEN, REVERSE_STR>
impl<const LEN: usize, const REVERSE_STR: bool> BitAndAssign for Array<u8, LEN, REVERSE_STR>
source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&=
operation. Read moresource§impl<const LEN: usize, const REVERSE_STR: bool> BitOrAssign for Array<u8, LEN, REVERSE_STR>
impl<const LEN: usize, const REVERSE_STR: bool> BitOrAssign for Array<u8, LEN, REVERSE_STR>
source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|=
operation. Read moresource§impl<const LEN: usize, const REVERSE_STR: bool> BitXorAssign for Array<u8, LEN, REVERSE_STR>
impl<const LEN: usize, const REVERSE_STR: bool> BitXorAssign for Array<u8, LEN, REVERSE_STR>
source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^=
operation. Read moresource§impl<T, const LEN: usize, const REVERSE_STR: bool> Borrow<[T]> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> Borrow<[T]> for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> BorrowMut<[T]> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> BorrowMut<[T]> for Array<T, LEN, REVERSE_STR>
source§fn borrow_mut(&mut self) -> &mut [T]
fn borrow_mut(&mut self) -> &mut [T]
source§impl<T: Clone, const LEN: usize, const REVERSE_STR: bool> Clone for Array<T, LEN, REVERSE_STR>
impl<T: Clone, const LEN: usize, const REVERSE_STR: bool> Clone for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> From<[T; LEN]> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> From<[T; LEN]> for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> Index<Range<usize>> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> Index<Range<usize>> for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> Index<RangeFrom<usize>> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> Index<RangeFrom<usize>> for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> Index<RangeFull> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> Index<RangeFull> for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> Index<RangeInclusive<usize>> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> Index<RangeInclusive<usize>> for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> Index<RangeTo<usize>> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> Index<RangeTo<usize>> for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> Index<RangeToInclusive<usize>> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> Index<RangeToInclusive<usize>> for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> Index<usize> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> Index<usize> for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> IndexMut<Range<usize>> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> IndexMut<Range<usize>> for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> IndexMut<RangeFrom<usize>> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> IndexMut<RangeFrom<usize>> for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> IndexMut<RangeFull> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> IndexMut<RangeFull> for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> IndexMut<RangeInclusive<usize>> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> IndexMut<RangeInclusive<usize>> for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> IndexMut<RangeTo<usize>> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> IndexMut<RangeTo<usize>> for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> IndexMut<RangeToInclusive<usize>> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> IndexMut<RangeToInclusive<usize>> for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> IndexMut<usize> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> IndexMut<usize> for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> IntoIterator for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> IntoIterator for Array<T, LEN, REVERSE_STR>
source§impl<T: Ord, const LEN: usize, const REVERSE_STR: bool> Ord for Array<T, LEN, REVERSE_STR>
impl<T: Ord, const LEN: usize, const REVERSE_STR: bool> Ord for Array<T, LEN, REVERSE_STR>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<T: PartialEq, const LEN: usize, const REVERSE_STR: bool> PartialEq for Array<T, LEN, REVERSE_STR>
impl<T: PartialEq, const LEN: usize, const REVERSE_STR: bool> PartialEq for Array<T, LEN, REVERSE_STR>
source§impl<T: PartialOrd, const LEN: usize, const REVERSE_STR: bool> PartialOrd for Array<T, LEN, REVERSE_STR>
impl<T: PartialOrd, const LEN: usize, const REVERSE_STR: bool> PartialOrd for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> TryFrom<&[T]> for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> TryFrom<&[T]> for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> Wrapper for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> Wrapper for Array<T, LEN, REVERSE_STR>
source§impl<T, const LEN: usize, const REVERSE_STR: bool> WrapperMut for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> WrapperMut for Array<T, LEN, REVERSE_STR>
source§fn as_inner_mut(&mut self) -> &mut Self::Inner
fn as_inner_mut(&mut self) -> &mut Self::Inner
impl<T: Copy, const LEN: usize, const REVERSE_STR: bool> Copy for Array<T, LEN, REVERSE_STR>
impl<T: Eq, const LEN: usize, const REVERSE_STR: bool> Eq for Array<T, LEN, REVERSE_STR>
impl<T, const LEN: usize, const REVERSE_STR: bool> StructuralPartialEq for Array<T, LEN, REVERSE_STR>
Auto Trait Implementations§
impl<T, const LEN: usize, const REVERSE_STR: bool> Freeze for Array<T, LEN, REVERSE_STR>where
T: Freeze,
impl<T, const LEN: usize, const REVERSE_STR: bool> RefUnwindSafe for Array<T, LEN, REVERSE_STR>where
T: RefUnwindSafe,
impl<T, const LEN: usize, const REVERSE_STR: bool> Send for Array<T, LEN, REVERSE_STR>where
T: Send,
impl<T, const LEN: usize, const REVERSE_STR: bool> Sync for Array<T, LEN, REVERSE_STR>where
T: Sync,
impl<T, const LEN: usize, const REVERSE_STR: bool> Unpin for Array<T, LEN, REVERSE_STR>where
T: Unpin,
impl<T, const LEN: usize, const REVERSE_STR: bool> UnwindSafe for Array<T, LEN, REVERSE_STR>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)