pub struct Parts<T>(/* private fields */);Expand description
Generic collection for Parts
§Serialize/Deserialize
Serialize and Deserialize are implemented for this type.
§Box (no Copy)
The inner array of this type is wrapped in a Box.
Fields within a Part already use a Box so we are forced to wrap the data in a Box here.
§Example: Extending in your own code with custom inner types
use ot_tools_io::types::Parts;
use std::path::PathBuf;
use ot_tools_io::Defaults;
use ot_tools_io_derive::{ArrayDefaults, BoxedArrayDefaults};
use std::array::from_fn;
#[derive(Debug, PartialEq, Default, ArrayDefaults, BoxedArrayDefaults)]
pub struct LongPartName(String);
let mut my_part_names = Parts::<LongPartName>::default();
let first = my_part_names.first_mut().ok_or(())?;
*first = LongPartName(String::from("My awesome part name that is too long on the octatrack"));
// first one changed
assert_eq!(
my_part_names[0],
LongPartName(
String::from("My awesome part name that is too long on the octatrack")
)
);
// rest are default
assert_eq!(my_part_names[1], LongPartName::default());
// correct length
assert_eq!(my_part_names.len(), 4);
Implementations§
Source§impl<T> Parts<T>
impl<T> Parts<T>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Parts<Part>
impl<'de> Deserialize<'de> for Parts<Part>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<T: Eq> Eq for Parts<T>
Source§impl HasHeaderField for Parts<Part>
impl HasHeaderField for Parts<Part>
Source§fn check_header(&self) -> Result<bool, OtToolsIoError>
fn check_header(&self) -> Result<bool, OtToolsIoError>
Method to verify if header(s) are valid in some data.
See this thread. Read more
Source§impl<T: Ord> Ord for Parts<T>
impl<T: Ord> Ord for Parts<T>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd> PartialOrd for Parts<T>
impl<T: PartialOrd> PartialOrd for Parts<T>
impl<T: PartialEq> StructuralPartialEq for Parts<T>
Auto Trait Implementations§
impl<T> Freeze for Parts<T>
impl<T> RefUnwindSafe for Parts<T>where
T: RefUnwindSafe,
impl<T> Send for Parts<T>where
T: Send,
impl<T> Sync for Parts<T>where
T: Sync,
impl<T> Unpin for Parts<T>
impl<T> UnsafeUnpin for Parts<T>
impl<T> UnwindSafe for Parts<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more