Compare commits
5 Commits
d6cb0fba1a
...
ba2e782af5
| Author | SHA1 | Date | |
|---|---|---|---|
| ba2e782af5 | |||
| 8ee03d953f | |||
| f218ff26c7 | |||
| 24f99f4cb8 | |||
| 905820384a |
@ -10,8 +10,7 @@ description = "Crossplatform (and web-compatible) graphing calculator"
|
|||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# Enable wayland support for running tests on native targets
|
wayland-native = ["eframe/wayland"]
|
||||||
native-test = ["eframe/wayland"]
|
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
debug = false
|
debug = false
|
||||||
|
|||||||
@ -77,7 +77,7 @@
|
|||||||
''
|
''
|
||||||
runHook preCheck
|
runHook preCheck
|
||||||
export LD_LIBRARY_PATH="${libPath}:$LD_LIBRARY_PATH"
|
export LD_LIBRARY_PATH="${libPath}:$LD_LIBRARY_PATH"
|
||||||
cargo test --workspace --features native-test
|
cargo test --workspace --features wayland-native
|
||||||
runHook postCheck
|
runHook postCheck
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|||||||
@ -9,53 +9,35 @@ use std::hash::{Hash, Hasher};
|
|||||||
use std::ops::BitXorAssign;
|
use std::ops::BitXorAssign;
|
||||||
|
|
||||||
type Functions = Vec<(Id, FunctionEntry)>;
|
type Functions = Vec<(Id, FunctionEntry)>;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct FunctionManager {
|
pub struct FunctionManager {
|
||||||
functions: Functions,
|
functions: Functions,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for FunctionManager {
|
impl Default for FunctionManager {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let mut vec: Functions = Vec::with_capacity(COLORS.len());
|
let mut d = Self {
|
||||||
vec.push((
|
functions: Vec::new()
|
||||||
Id::new(11414819524356497634_u64), // Random number here to avoid call to crate::misc::random_u64()
|
};
|
||||||
FunctionEntry::default(),
|
d.push_empty();
|
||||||
));
|
d
|
||||||
Self { functions: vec }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for FunctionManager {
|
#[test]
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn func_manager_roundtrip_serdes() {
|
||||||
where
|
let mut func_manager = FunctionManager {
|
||||||
S: Serializer,
|
functions: Vec::new(),
|
||||||
{
|
};
|
||||||
let mut s = serializer.serialize_struct("FunctionManager", 1)?;
|
|
||||||
s.serialize_field(
|
|
||||||
"data",
|
|
||||||
&self
|
|
||||||
.functions
|
|
||||||
.iter()
|
|
||||||
.map(|(id, func)| (*id, func.clone()))
|
|
||||||
.collect::<Vec<(Id, FunctionEntry)>>(),
|
|
||||||
)?;
|
|
||||||
s.end()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'de> Deserialize<'de> for FunctionManager {
|
func_manager.push_empty();
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
let ser = bincode::serialize(&func_manager).expect("unable to serialize");
|
||||||
where
|
let des: FunctionManager = bincode::deserialize(&ser).expect("unable to deserialize");
|
||||||
D: Deserializer<'de>,
|
assert_eq!(
|
||||||
{
|
func_manager.functions[0].1.raw_func_str,
|
||||||
#[derive(Deserialize)]
|
des.functions[0].1.raw_func_str
|
||||||
struct Helper(Vec<(Id, FunctionEntry)>);
|
);
|
||||||
|
|
||||||
let helper = Helper::deserialize(deserializer)?;
|
|
||||||
|
|
||||||
Ok(FunctionManager {
|
|
||||||
functions: helper.0.to_vec(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Function that creates button that's used with the `button_area`
|
/// Function that creates button that's used with the `button_area`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user