Skip to content

Commit 536da58

Browse files
authored
Rename AssociatedArraySize => AssocArraySize (#40)
The new name is still long, but at least a little bit shorter
1 parent 4263cc4 commit 536da58

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

Diff for: src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ use typenum::{Diff, Sum};
112112
use zeroize::{Zeroize, ZeroizeOnDrop};
113113

114114
/// Type alias for [`Array`] which is const generic around a size `N`, ala `[T; N]`.
115-
pub type ArrayN<T, const N: usize> = Array<T, <[T; N] as AssociatedArraySize>::Size>;
115+
pub type ArrayN<T, const N: usize> = Array<T, <[T; N] as AssocArraySize>::Size>;
116116

117117
/// [`Array`] is a newtype for an inner `[T; N]` array where `N` is determined by a generic
118118
/// [`ArraySize`] parameter, which is a marker trait for a numeric value determined by ZSTs that
@@ -134,25 +134,25 @@ pub type ArrayN<T, const N: usize> = Array<T, <[T; N] as AssociatedArraySize>::S
134134
/// The [`AsRef`] trait can be used to convert from `&Array<T, U>` to `&[T; N]` and vice versa:
135135
///
136136
/// ```
137-
/// use hybrid_array::{Array, ArraySize, AssociatedArraySize, ArrayN, consts::U3};
137+
/// use hybrid_array::{Array, ArraySize, AssocArraySize, ArrayN, consts::U3};
138138
///
139139
/// pub fn get_third_item_hybrid_array<T, U: ArraySize>(arr_ref: &Array<T, U>) -> &T {
140140
/// &arr_ref[2]
141141
/// }
142142
///
143143
/// pub fn get_third_item_const_generic<T, const N: usize>(arr_ref: &[T; N]) -> &T
144144
/// where
145-
/// [T; N]: AssociatedArraySize + AsRef<ArrayN<T, N>>
145+
/// [T; N]: AssocArraySize + AsRef<ArrayN<T, N>>
146146
/// {
147147
/// get_third_item_hybrid_array(arr_ref.as_ref())
148148
/// }
149149
///
150150
/// assert_eq!(get_third_item_const_generic(&[1u8, 2, 3, 4]), &3);
151151
/// ```
152152
///
153-
/// Note that the [`AssociatedArraySize`] trait can be used to determine the appropriate
153+
/// Note that the [`AssocArraySize`] trait can be used to determine the appropriate
154154
/// [`Array`] size for a given `[T; N]`, and the [`ArrayN`] trait (which internally uses
155-
/// [`AssociatedArraySize`]) can be used to determine the specific [`Array`] type for a given
155+
/// [`AssocArraySize`]) can be used to determine the specific [`Array`] type for a given
156156
/// const generic size.
157157
#[repr(transparent)]
158158
pub struct Array<T, U: ArraySize>(pub U::ArrayType<T>);

Diff for: src/sizes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Macros for defining various array sizes, and their associated invocations.
22
3-
use super::{ArraySize, AssociatedArraySize};
3+
use super::{ArraySize, AssocArraySize};
44

55
macro_rules! impl_array_size {
66
($($len:expr => $ty:ident),+) => {
@@ -9,7 +9,7 @@ macro_rules! impl_array_size {
99
type ArrayType<T> = [T; $len];
1010
}
1111

12-
impl<T> AssociatedArraySize for [T; $len] {
12+
impl<T> AssocArraySize for [T; $len] {
1313
type Size = typenum::$ty;
1414
}
1515
)+

Diff for: src/traits.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub unsafe trait ArraySize: Unsigned {
2222
///
2323
/// This is always defined to be `[T; N]` where `N` is the same as
2424
/// [`ArraySize::USIZE`][`typenum::Unsigned::USIZE`].
25-
type ArrayType<T>: AssociatedArraySize<Size = Self>
25+
type ArrayType<T>: AssocArraySize<Size = Self>
2626
+ AsRef<[T]>
2727
+ AsMut<[T]>
2828
+ Borrow<[T]>
@@ -37,12 +37,12 @@ pub unsafe trait ArraySize: Unsigned {
3737
}
3838

3939
/// Associates an [`ArraySize`] with a given type.
40-
pub trait AssociatedArraySize: Sized {
40+
pub trait AssocArraySize: Sized {
4141
/// Size of an array type, expressed as a [`typenum`]-based [`ArraySize`].
4242
type Size: ArraySize;
4343
}
4444

45-
impl<T, U> AssociatedArraySize for Array<T, U>
45+
impl<T, U> AssocArraySize for Array<T, U>
4646
where
4747
U: ArraySize,
4848
{

0 commit comments

Comments
 (0)