flatipc: run cargo +nightly fmt -p flatipc

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2024-09-22 18:49:56 +08:00
parent a77fdac6f0
commit c8d70aae6a
2 changed files with 13 additions and 39 deletions

View file

@ -7,12 +7,8 @@ pub struct String<const N: usize> {
unsafe impl<const N: usize> crate::IpcSafe for String<N> {}
impl<const N: usize> String<N> {
pub fn new() -> Self {
String {
buffer: [0; N],
length: 0,
}
}
pub fn new() -> Self { String { buffer: [0; N], length: 0 } }
pub fn from_str(s: &str) -> Self {
let mut buffer = [0; N];
let length = s.len();
@ -22,9 +18,7 @@ impl<const N: usize> String<N> {
}
impl<const N: usize> From<&str> for String<N> {
fn from(value: &str) -> Self {
Self::from_str(value)
}
fn from(value: &str) -> Self { Self::from_str(value) }
}
impl<const N: usize> core::fmt::Write for String<N> {
@ -46,9 +40,7 @@ impl<const N: usize> core::fmt::Debug for String<N> {
}
impl<const N: usize> Default for String<N> {
fn default() -> Self {
String::new()
}
fn default() -> Self { String::new() }
}
impl<const N: usize> core::fmt::Display for String<N> {

View file

@ -29,9 +29,7 @@ impl<T, const N: usize> Vec<T, N> {
}
}
pub fn len(&self) -> usize {
self.length
}
pub fn len(&self) -> usize { self.length }
pub fn as_slice(&self) -> &[T] {
unsafe { core::slice::from_raw_parts(self.buffer.as_ptr() as *const T, self.length) }
@ -50,13 +48,9 @@ impl<T, const N: usize> Vec<T, N> {
self.length = 0;
}
pub fn iter(&self) -> core::slice::Iter<'_, T> {
self.as_slice().iter()
}
pub fn iter(&self) -> core::slice::Iter<'_, T> { self.as_slice().iter() }
pub fn iter_mut(&mut self) -> core::slice::IterMut<'_, T> {
self.as_mut_slice().iter_mut()
}
pub fn iter_mut(&mut self) -> core::slice::IterMut<'_, T> { self.as_mut_slice().iter_mut() }
pub fn resize(&mut self, new_len: usize, value: T)
where
@ -73,9 +67,7 @@ impl<T, const N: usize> Vec<T, N> {
}
impl<T, const N: usize> Drop for Vec<T, N> {
fn drop(&mut self) {
self.clear();
}
fn drop(&mut self) { self.clear(); }
}
impl<T, const N: usize> core::fmt::Debug for Vec<T, N>
@ -88,23 +80,17 @@ where
}
impl<T, const N: usize> Default for Vec<T, N> {
fn default() -> Self {
Vec::new()
}
fn default() -> Self { Vec::new() }
}
impl<T, const N: usize> core::ops::Deref for Vec<T, N> {
type Target = [T];
fn deref(&self) -> &Self::Target {
self.as_slice()
}
fn deref(&self) -> &Self::Target { self.as_slice() }
}
impl<T, const N: usize> core::ops::DerefMut for Vec<T, N> {
fn deref_mut(&mut self) -> &mut Self::Target {
self.as_mut_slice()
}
fn deref_mut(&mut self) -> &mut Self::Target { self.as_mut_slice() }
}
impl<T, const N: usize> From<&[T]> for Vec<T, N>
@ -151,13 +137,9 @@ where
impl<T, const N: usize> core::ops::Index<usize> for Vec<T, N> {
type Output = T;
fn index(&self, index: usize) -> &Self::Output {
&self.as_slice()[index]
}
fn index(&self, index: usize) -> &Self::Output { &self.as_slice()[index] }
}
impl<T, const N: usize> core::ops::IndexMut<usize> for Vec<T, N> {
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
&mut self.as_mut_slice()[index]
}
fn index_mut(&mut self, index: usize) -> &mut Self::Output { &mut self.as_mut_slice()[index] }
}