pub struct IdOrdMapAsMap<T> { /* private fields */ }Expand description
Marker type for IdOrdMap serialized as a map, for use with serde’s
with attribute.
§Examples
Use with serde’s with attribute:
use iddqd::{IdOrdItem, IdOrdMap, id_ord_map::IdOrdMapAsMap, id_upcast};
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
struct Item {
id: u32,
name: String,
}
impl IdOrdItem for Item {
type Key<'a> = u32;
fn key(&self) -> Self::Key<'_> {
self.id
}
id_upcast!();
}
#[derive(Serialize, Deserialize)]
struct Config {
#[serde(with = "IdOrdMapAsMap")]
items: IdOrdMap<Item>,
}§Requirements
- For serialization, the key type must implement
Serialize. - For JSON serialization, the key should be string-like or convertible to a string key.
Implementations§
Source§impl<T> IdOrdMapAsMap<T>
impl<T> IdOrdMapAsMap<T>
Auto Trait Implementations§
impl<T> Freeze for IdOrdMapAsMap<T>
impl<T> RefUnwindSafe for IdOrdMapAsMap<T>
impl<T> Send for IdOrdMapAsMap<T>
impl<T> Sync for IdOrdMapAsMap<T>
impl<T> Unpin for IdOrdMapAsMap<T>
impl<T> UnwindSafe for IdOrdMapAsMap<T>
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