Skip to content

Commit 6a8ac57

Browse files
committed
Fix missing docs
1 parent 2031f9e commit 6a8ac57

File tree

5 files changed

+23
-33
lines changed

5 files changed

+23
-33
lines changed

src/hex.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ where
4141
res[i * 2] = LOWER_CHARS[(c >> 4) as usize];
4242
res[i * 2 + 1] = LOWER_CHARS[(c & 0xF) as usize];
4343
}
44-
f.write_str(
45-
unsafe { str::from_utf8_unchecked(&res[..max_digits * 2]) },
46-
)?;
44+
f.write_str(unsafe { str::from_utf8_unchecked(&res[..max_digits * 2]) })?;
4745
} else {
4846
// For large array use chunks of up to 1024 bytes (2048 hex chars)
4947
let mut buf = [0u8; 2048];
@@ -53,9 +51,7 @@ where
5351
buf[i * 2] = LOWER_CHARS[(c >> 4) as usize];
5452
buf[i * 2 + 1] = LOWER_CHARS[(c & 0xF) as usize];
5553
}
56-
f.write_str(unsafe {
57-
str::from_utf8_unchecked(&buf[..chunk.len() * 2])
58-
})?;
54+
f.write_str(unsafe { str::from_utf8_unchecked(&buf[..chunk.len() * 2]) })?;
5955
}
6056
}
6157
Ok(())
@@ -79,9 +75,7 @@ where
7975
res[i * 2] = UPPER_CHARS[(c >> 4) as usize];
8076
res[i * 2 + 1] = UPPER_CHARS[(c & 0xF) as usize];
8177
}
82-
f.write_str(
83-
unsafe { str::from_utf8_unchecked(&res[..max_digits * 2]) },
84-
)?;
78+
f.write_str(unsafe { str::from_utf8_unchecked(&res[..max_digits * 2]) })?;
8579
} else {
8680
// For large array use chunks of up to 1024 bytes (2048 hex chars)
8781
let mut buf = [0u8; 2048];
@@ -91,9 +85,7 @@ where
9185
buf[i * 2] = UPPER_CHARS[(c >> 4) as usize];
9286
buf[i * 2 + 1] = UPPER_CHARS[(c & 0xF) as usize];
9387
}
94-
f.write_str(unsafe {
95-
str::from_utf8_unchecked(&buf[..chunk.len() * 2])
96-
})?;
88+
f.write_str(unsafe { str::from_utf8_unchecked(&buf[..chunk.len() * 2]) })?;
9789
}
9890
}
9991
Ok(())

src/impl_serde.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ where
4242
{
4343
let mut result = GenericArray::default();
4444
for i in 0..N::to_usize() {
45-
result[i] = seq.next_element()?.ok_or_else(
46-
|| de::Error::invalid_length(i, &self),
47-
)?;
45+
result[i] = seq.next_element()?
46+
.ok_or_else(|| de::Error::invalid_length(i, &self))?;
4847
}
4948
Ok(result)
5049
}

src/impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,4 @@ impl_from! {
168168
30 => ::typenum::U30,
169169
31 => ::typenum::U31,
170170
32 => ::typenum::U32
171-
}
171+
}

src/lib.rs

+15-16
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
#![deny(missing_docs)]
4040
#![no_std]
4141

42-
pub extern crate typenum;
4342
#[cfg(feature = "serde")]
4443
extern crate serde;
44+
pub extern crate typenum;
4545

4646
mod hex;
4747
mod impls;
@@ -50,11 +50,9 @@ mod impls;
5050
pub mod impl_serde;
5151

5252
use core::{mem, ptr, slice};
53-
5453
use core::marker::PhantomData;
5554
use core::mem::ManuallyDrop;
5655
use core::ops::{Deref, DerefMut};
57-
5856
use typenum::bit::{B0, B1};
5957
use typenum::uint::{UInt, UTerm, Unsigned};
6058

@@ -298,10 +296,10 @@ where
298296

299297
let mut destination = ArrayBuilder::new();
300298

301-
for (dst, (lhs, rhs)) in
302-
destination.array.iter_mut().zip(left.array.iter().zip(
303-
right.array.iter(),
304-
))
299+
for (dst, (lhs, rhs)) in destination
300+
.array
301+
.iter_mut()
302+
.zip(left.array.iter().zip(right.array.iter()))
305303
{
306304
unsafe {
307305
ptr::write(dst, f(ptr::read(lhs), ptr::read(rhs)));
@@ -324,9 +322,7 @@ where
324322
F: Fn(&T, &B) -> U,
325323
N: ArrayLength<B> + ArrayLength<U>,
326324
{
327-
GenericArray::generate(|i| unsafe {
328-
f(self.get_unchecked(i), rhs.get_unchecked(i))
329-
})
325+
GenericArray::generate(|i| unsafe { f(self.get_unchecked(i), rhs.get_unchecked(i)) })
330326
}
331327

332328
/// Extracts a slice containing the entire array.
@@ -371,9 +367,8 @@ where
371367
/// Length of the slice must be equal to the length of the array
372368
#[inline]
373369
pub fn clone_from_slice(list: &[T]) -> GenericArray<T, N> {
374-
Self::from_exact_iter(list.iter().cloned()).expect(
375-
"Slice must be the same length as the array",
376-
)
370+
Self::from_exact_iter(list.iter().cloned())
371+
.expect("Slice must be the same length as the array")
377372
}
378373
}
379374

@@ -426,9 +421,10 @@ where
426421

427422
let defaults = ::core::iter::repeat(()).map(|_| T::default());
428423

429-
for (dst, src) in destination.array.iter_mut().zip(
430-
iter.into_iter().chain(defaults),
431-
)
424+
for (dst, src) in destination
425+
.array
426+
.iter_mut()
427+
.zip(iter.into_iter().chain(defaults))
432428
{
433429
unsafe {
434430
ptr::write(dst, src);
@@ -439,7 +435,10 @@ where
439435
}
440436
}
441437

438+
/// A reimplementation of the `transmute` function, avoiding problems
439+
/// when the compiler can't prove equal sizes.
442440
#[inline]
441+
#[doc(hidden)]
443442
pub unsafe fn transmute<A, B>(a: A) -> B {
444443
let b = ::core::ptr::read(&a as *const A as *const B);
445444
::core::mem::forget(a);

src/sequence.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub unsafe trait Shorten<T>: GenericSequence<T> {
7575
fn pop_back(self) -> (Self::Shorter, T);
7676

7777
/// Returns a new array without the first element, and the first element.
78-
/// Example:
78+
/// Example:
7979
///
8080
/// ```ignore
8181
/// let a = arr![i32; 1, 2, 3, 4];

0 commit comments

Comments
 (0)