Skip to content

Commit 1e96864

Browse files
committed
Version 0.12.3
1 parent 04fe34c commit 1e96864

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "generic-array"
4-
version = "0.12.0"
4+
version = "0.12.3"
55
authors = [ "Bartłomiej Kamiński <[email protected]>", "Aaron Trent <[email protected]>" ]
66

77
description = "Generic types implementing functionality of arrays"

src/impls.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ where
2121
N: ArrayLength<T>,
2222
{
2323
fn clone(&self) -> GenericArray<T, N> {
24-
self.map(|x| x.clone())
24+
self.map(Clone::clone)
2525
}
2626
}
2727

@@ -77,6 +77,7 @@ impl<T, N> Borrow<[T]> for GenericArray<T, N>
7777
where
7878
N: ArrayLength<T>,
7979
{
80+
#[inline(always)]
8081
fn borrow(&self) -> &[T] {
8182
&self[..]
8283
}
@@ -86,6 +87,7 @@ impl<T, N> BorrowMut<[T]> for GenericArray<T, N>
8687
where
8788
N: ArrayLength<T>,
8889
{
90+
#[inline(always)]
8991
fn borrow_mut(&mut self) -> &mut [T] {
9092
&mut self[..]
9193
}
@@ -95,6 +97,7 @@ impl<T, N> AsRef<[T]> for GenericArray<T, N>
9597
where
9698
N: ArrayLength<T>,
9799
{
100+
#[inline(always)]
98101
fn as_ref(&self) -> &[T] {
99102
&self[..]
100103
}
@@ -104,6 +107,7 @@ impl<T, N> AsMut<[T]> for GenericArray<T, N>
104107
where
105108
N: ArrayLength<T>,
106109
{
110+
#[inline(always)]
107111
fn as_mut(&mut self) -> &mut [T] {
108112
&mut self[..]
109113
}
@@ -125,11 +129,16 @@ macro_rules! impl_from {
125129
($($n: expr => $ty: ty),*) => {
126130
$(
127131
impl<T> From<[T; $n]> for GenericArray<T, $ty> {
132+
#[inline(always)]
128133
fn from(arr: [T; $n]) -> Self {
129-
use core::mem::{forget, transmute_copy};
130-
let x = unsafe { transmute_copy(&arr) };
131-
forget(arr);
132-
x
134+
unsafe { $crate::transmute(arr) }
135+
}
136+
}
137+
138+
impl<T> Into<[T; $n]> for GenericArray<T, $ty> {
139+
#[inline(always)]
140+
fn into(self) -> [T; $n] {
141+
unsafe { $crate::transmute(self) }
133142
}
134143
}
135144
)*

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ where
151151
{
152152
type Target = [T];
153153

154+
#[inline(always)]
154155
fn deref(&self) -> &[T] {
155156
unsafe { slice::from_raw_parts(self as *const Self as *const T, N::to_usize()) }
156157
}
@@ -160,6 +161,7 @@ impl<T, N> DerefMut for GenericArray<T, N>
160161
where
161162
N: ArrayLength<T>,
162163
{
164+
#[inline(always)]
163165
fn deref_mut(&mut self) -> &mut [T] {
164166
unsafe { slice::from_raw_parts_mut(self as *mut Self as *mut T, N::to_usize()) }
165167
}

0 commit comments

Comments
 (0)