2022-08-02 12:21:07 +00:00
|
|
|
macro_rules! impl_from_repeated {
|
2021-12-07 22:22:24 +00:00
|
|
|
($src:ty, $dst:ty) => {
|
|
|
|
impl From<&[$src]> for $dst {
|
|
|
|
fn from(src: &[$src]) -> Self {
|
|
|
|
let result = src.iter().map(From::from).collect();
|
|
|
|
Self(result)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-08-02 12:21:07 +00:00
|
|
|
pub(crate) use impl_from_repeated;
|
2021-12-07 22:22:24 +00:00
|
|
|
|
2022-08-02 12:21:07 +00:00
|
|
|
macro_rules! impl_from_repeated_copy {
|
2021-12-07 22:22:24 +00:00
|
|
|
($src:ty, $dst:ty) => {
|
|
|
|
impl From<&[$src]> for $dst {
|
|
|
|
fn from(src: &[$src]) -> Self {
|
2022-08-02 12:21:07 +00:00
|
|
|
let result = src.iter().copied().collect();
|
2021-12-07 22:22:24 +00:00
|
|
|
Self(result)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-08-02 12:21:07 +00:00
|
|
|
pub(crate) use impl_from_repeated_copy;
|
2021-12-07 22:22:24 +00:00
|
|
|
|
2022-08-02 12:21:07 +00:00
|
|
|
macro_rules! impl_try_from_repeated {
|
2021-12-07 22:22:24 +00:00
|
|
|
($src:ty, $dst:ty) => {
|
|
|
|
impl TryFrom<&[$src]> for $dst {
|
2021-12-26 20:18:42 +00:00
|
|
|
type Error = librespot_core::Error;
|
2021-12-07 22:22:24 +00:00
|
|
|
fn try_from(src: &[$src]) -> Result<Self, Self::Error> {
|
|
|
|
let result: Result<Vec<_>, _> = src.iter().map(TryFrom::try_from).collect();
|
|
|
|
Ok(Self(result?))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-08-02 12:21:07 +00:00
|
|
|
pub(crate) use impl_try_from_repeated;
|
2022-08-02 10:45:37 +00:00
|
|
|
|
|
|
|
macro_rules! impl_deref_wrapped {
|
|
|
|
($wrapper:ty, $inner:ty) => {
|
|
|
|
impl Deref for $wrapper {
|
|
|
|
type Target = $inner;
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
&self.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl DerefMut for $wrapper {
|
|
|
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
|
|
|
&mut self.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) use impl_deref_wrapped;
|