Add serde derive to PrimaryMap
This commit is contained in:
@@ -11,10 +11,14 @@ readme = "README.md"
|
|||||||
keywords = ["entity", "set", "map"]
|
keywords = ["entity", "set", "map"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde = { version = "1.0.94", features = ["derive"], optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = []
|
std = []
|
||||||
core = []
|
core = []
|
||||||
|
enable-serde = ["serde"]
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
maintenance = { status = "experimental" }
|
maintenance = { status = "experimental" }
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ use core::iter::FromIterator;
|
|||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use core::ops::{Index, IndexMut};
|
use core::ops::{Index, IndexMut};
|
||||||
use core::slice;
|
use core::slice;
|
||||||
|
#[cfg(feature = "enable-serde")]
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use std::boxed::Box;
|
use std::boxed::Box;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
|
|
||||||
@@ -26,6 +28,7 @@ use std::vec::Vec;
|
|||||||
/// plain slice would make it easier to use incorrectly. To make a slice of a `PrimaryMap`, use
|
/// plain slice would make it easier to use incorrectly. To make a slice of a `PrimaryMap`, use
|
||||||
/// `into_boxed_slice`.
|
/// `into_boxed_slice`.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct PrimaryMap<K, V>
|
pub struct PrimaryMap<K, V>
|
||||||
where
|
where
|
||||||
K: EntityRef,
|
K: EntityRef,
|
||||||
|
|||||||
Reference in New Issue
Block a user