Merge pull request #512 from sourcebox/doc-fixes

Rustdoc clippy and typo fixes
This commit is contained in:
Dario Nieuwenhuis 2024-10-07 13:29:51 +00:00 committed by GitHub
commit 8ab2335382
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 14 additions and 17 deletions

View File

@ -1125,7 +1125,7 @@ where
/// Remove the key-value pair equivalent to `key` and return its value. /// Remove the key-value pair equivalent to `key` and return its value.
/// ///
/// Like `Vec::swap_remove`, the pair is removed by swapping it with the last element of the map /// Like `Vec::swap_remove`, the pair is removed by swapping it with the last element of the map
/// and popping it off. **This perturbs the postion of what used to be the last element!** /// and popping it off. **This perturbs the position of what used to be the last element!**
/// ///
/// Return `None` if `key` is not in map. /// Return `None` if `key` is not in map.
/// ///

View File

@ -151,8 +151,6 @@ pub type MpMcQueue<T, const N: usize> = MpMcQueueInner<T, OwnedStorage<N>>;
pub type MpMcQueueView<T> = MpMcQueueInner<T, ViewStorage>; pub type MpMcQueueView<T> = MpMcQueueInner<T, ViewStorage>;
impl<T, const N: usize> MpMcQueue<T, N> { impl<T, const N: usize> MpMcQueue<T, N> {
const EMPTY_CELL: Cell<T> = Cell::new(0);
const ASSERT: [(); 1] = [()]; const ASSERT: [(); 1] = [()];
/// Creates an empty queue /// Creates an empty queue
@ -167,7 +165,7 @@ impl<T, const N: usize> MpMcQueue<T, N> {
let mut cell_count = 0; let mut cell_count = 0;
let mut result_cells: [Cell<T>; N] = [Self::EMPTY_CELL; N]; let mut result_cells: [Cell<T>; N] = [const { Cell::new(0) }; N];
while cell_count != N { while cell_count != N {
result_cells[cell_count] = Cell::new(cell_count); result_cells[cell_count] = Cell::new(cell_count);
cell_count += 1; cell_count += 1;

View File

@ -135,7 +135,6 @@ pub type Queue<T, const N: usize> = QueueInner<T, OwnedStorage<N>>;
pub type QueueView<T> = QueueInner<T, ViewStorage>; pub type QueueView<T> = QueueInner<T, ViewStorage>;
impl<T, const N: usize> Queue<T, N> { impl<T, const N: usize> Queue<T, N> {
const INIT: UnsafeCell<MaybeUninit<T>> = UnsafeCell::new(MaybeUninit::uninit());
/// Creates an empty queue with a fixed capacity of `N - 1` /// Creates an empty queue with a fixed capacity of `N - 1`
pub const fn new() -> Self { pub const fn new() -> Self {
// Const assert N > 1 // Const assert N > 1
@ -144,7 +143,7 @@ impl<T, const N: usize> Queue<T, N> {
Queue { Queue {
head: AtomicUsize::new(0), head: AtomicUsize::new(0),
tail: AtomicUsize::new(0), tail: AtomicUsize::new(0),
buffer: [Self::INIT; N], buffer: [const { UnsafeCell::new(MaybeUninit::uninit()) }; N],
} }
} }

View File

@ -1027,7 +1027,7 @@ mod tests {
let s: String<4> = String::try_from("ab").unwrap(); let s: String<4> = String::try_from("ab").unwrap();
let b: Vec<u8, 4> = s.into_bytes(); let b: Vec<u8, 4> = s.into_bytes();
assert_eq!(b.len(), 2); assert_eq!(b.len(), 2);
assert_eq!(&[b'a', b'b'], &b[..]); assert_eq!(b"ab", &b[..]);
} }
#[test] #[test]
@ -1102,7 +1102,7 @@ mod tests {
match s.pop() { match s.pop() {
Some(c) => { Some(c) => {
assert_eq!(s.len(), 1); assert_eq!(s.len(), 1);
assert_eq!(c, '\u{0301}'); // accute accent of e assert_eq!(c, '\u{0301}'); // acute accent of e
} }
None => panic!(), None => panic!(),
}; };