From c8d70aae6a64eef4e752a2494fdc03032fb1c8ba Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Sun, 22 Sep 2024 18:49:56 +0800 Subject: [PATCH] flatipc: run cargo +nightly fmt -p flatipc Signed-off-by: Sean Cross --- libs/flatipc/src/string.rs | 16 ++++------------ libs/flatipc/src/vec.rs | 36 +++++++++--------------------------- 2 files changed, 13 insertions(+), 39 deletions(-) diff --git a/libs/flatipc/src/string.rs b/libs/flatipc/src/string.rs index 942ee8fca..c43d64a4a 100644 --- a/libs/flatipc/src/string.rs +++ b/libs/flatipc/src/string.rs @@ -7,12 +7,8 @@ pub struct String { unsafe impl crate::IpcSafe for String {} impl String { - 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 String { } impl From<&str> for String { - fn from(value: &str) -> Self { - Self::from_str(value) - } + fn from(value: &str) -> Self { Self::from_str(value) } } impl core::fmt::Write for String { @@ -46,9 +40,7 @@ impl core::fmt::Debug for String { } impl Default for String { - fn default() -> Self { - String::new() - } + fn default() -> Self { String::new() } } impl core::fmt::Display for String { diff --git a/libs/flatipc/src/vec.rs b/libs/flatipc/src/vec.rs index 3338c9aea..5fd96cc26 100644 --- a/libs/flatipc/src/vec.rs +++ b/libs/flatipc/src/vec.rs @@ -29,9 +29,7 @@ impl Vec { } } - 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 Vec { 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 Vec { } impl Drop for Vec { - fn drop(&mut self) { - self.clear(); - } + fn drop(&mut self) { self.clear(); } } impl core::fmt::Debug for Vec @@ -88,23 +80,17 @@ where } impl Default for Vec { - fn default() -> Self { - Vec::new() - } + fn default() -> Self { Vec::new() } } impl core::ops::Deref for Vec { type Target = [T]; - fn deref(&self) -> &Self::Target { - self.as_slice() - } + fn deref(&self) -> &Self::Target { self.as_slice() } } impl core::ops::DerefMut for Vec { - 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 From<&[T]> for Vec @@ -151,13 +137,9 @@ where impl core::ops::Index for Vec { 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 core::ops::IndexMut for Vec { - 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] } }