Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove maplit dependency and stop using a macro for hashmaps #982

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ humantime = "2.1.0"
hyper = { version = "0.14.28", features = ["server", "tcp", "http1"] }
jod-thread = "0.1.2"
log = "0.4.21"
maplit = "1.0.2"
num_cpus = "1.16.0"
opener = "0.5.2"
rayon = "1.9.0"
Expand Down
29 changes: 13 additions & 16 deletions src/snapshot/patch_apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ mod test {

use std::borrow::Cow;

use maplit::hashmap;
use rbx_dom_weak::types::Variant;

use super::super::PatchAdd;
Expand All @@ -322,9 +321,7 @@ mod test {
metadata: Default::default(),
name: Cow::Borrowed("Foo"),
class_name: Cow::Borrowed("Bar"),
properties: hashmap! {
"Baz".to_owned() => Variant::Int32(5),
},
properties: [("Baz".to_owned(), Variant::Int32(5))].into(),
children: Vec::new(),
};

Expand Down Expand Up @@ -367,16 +364,15 @@ mod test {
id: root_id,
changed_name: Some("Foo".to_owned()),
changed_class_name: Some("NewClassName".to_owned()),
changed_properties: hashmap! {
changed_properties: [
// The value of Foo has changed
"Foo".to_owned() => Some(Variant::Int32(8)),

("Foo".to_owned(), Some(Variant::Int32(8))),
// Bar has been deleted
"Bar".to_owned() => None,

("Bar".to_owned(), None),
// Baz has been added
"Baz".to_owned() => Some(Variant::Int32(10)),
},
("Baz".to_owned(), Some(Variant::Int32(10))),
]
.into(),
changed_metadata: None,
};

Expand All @@ -387,11 +383,12 @@ mod test {

apply_patch_set(&mut tree, patch_set);

let expected_properties = hashmap! {
"Foo".to_owned() => Variant::Int32(8),
"Baz".to_owned() => Variant::Int32(10),
"Unchanged".to_owned() => Variant::Int32(-5),
};
let expected_properties = [
("Foo".to_owned(), Variant::Int32(8)),
("Baz".to_owned(), Variant::Int32(10)),
("Unchanged".to_owned(), Variant::Int32(-5)),
]
.into();

let root_instance = tree.get_instance(root_id).unwrap();
assert_eq!(root_instance.name(), "Foo");
Expand Down
18 changes: 4 additions & 14 deletions src/snapshot/patch_compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,6 @@ mod test {

use std::borrow::Cow;

use maplit::hashmap;

/// This test makes sure that rewriting refs in instance update patches to
/// instances that already exists works. We should be able to correlate the
/// snapshot ID and instance ID during patch computation and replace the
Expand All @@ -316,9 +314,7 @@ mod test {
let snapshot_id = Ref::new();
let snapshot = InstanceSnapshot {
snapshot_id: snapshot_id,
properties: hashmap! {
"Self".to_owned() => Variant::Ref(snapshot_id),
},
properties: [("Self".to_owned(), Variant::Ref(snapshot_id))].into(),

metadata: Default::default(),
name: Cow::Borrowed("foo"),
Expand All @@ -333,9 +329,7 @@ mod test {
id: root_id,
changed_name: None,
changed_class_name: None,
changed_properties: hashmap! {
"Self".to_owned() => Some(Variant::Ref(root_id)),
},
changed_properties: [("Self".to_owned(), Some(Variant::Ref(root_id)))].into(),
changed_metadata: None,
}],
added_instances: Vec::new(),
Expand All @@ -359,9 +353,7 @@ mod test {
let snapshot = InstanceSnapshot {
snapshot_id: snapshot_id,
children: vec![InstanceSnapshot {
properties: hashmap! {
"Self".to_owned() => Variant::Ref(snapshot_id),
},
properties: [("Self".to_owned(), Variant::Ref(snapshot_id))].into(),

snapshot_id: Ref::none(),
metadata: Default::default(),
Expand All @@ -384,9 +376,7 @@ mod test {
instance: InstanceSnapshot {
snapshot_id: Ref::none(),
metadata: Default::default(),
properties: hashmap! {
"Self".to_owned() => Variant::Ref(root_id),
},
properties: [("Self".to_owned(), Variant::Ref(root_id))].into(),
name: Cow::Borrowed("child"),
class_name: Cow::Borrowed("child"),
children: Vec::new(),
Expand Down
9 changes: 2 additions & 7 deletions src/snapshot/tests/apply.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use insta::assert_yaml_snapshot;
use maplit::hashmap;

use rojo_insta_ext::RedactionMap;

Expand Down Expand Up @@ -47,9 +46,7 @@ fn add_property() {
id: tree.get_root_id(),
changed_name: None,
changed_class_name: None,
changed_properties: hashmap! {
"Foo".to_owned() => Some("Value of Foo".into()),
},
changed_properties: [("Foo".to_owned(), Some("Value of Foo".into()))].into(),
changed_metadata: None,
}],
..Default::default()
Expand Down Expand Up @@ -88,9 +85,7 @@ fn remove_property() {
id: tree.get_root_id(),
changed_name: None,
changed_class_name: None,
changed_properties: hashmap! {
"Foo".to_owned() => None,
},
changed_properties: [("Foo".to_owned(), None).into()].into(),
changed_metadata: None,
}],
..Default::default()
Expand Down
5 changes: 1 addition & 4 deletions src/snapshot/tests/compute.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::borrow::Cow;

use insta::assert_yaml_snapshot;
use maplit::hashmap;

use rbx_dom_weak::types::Ref;
use rojo_insta_ext::RedactionMap;
Expand Down Expand Up @@ -42,9 +41,7 @@ fn set_property() {
metadata: Default::default(),
name: Cow::Borrowed("ROOT"),
class_name: Cow::Borrowed("ROOT"),
properties: hashmap! {
"PropertyName".to_owned() => "Hello, world!".into(),
},
properties: [("PropertyName".into(), "Hello, world!".into())].into(),
children: Vec::new(),
};

Expand Down
5 changes: 1 addition & 4 deletions src/snapshot_middleware/csv.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::{collections::BTreeMap, path::Path};

use anyhow::Context;
use maplit::hashmap;
use memofs::{IoResultExt, Vfs};
use serde::Serialize;

Expand Down Expand Up @@ -31,9 +30,7 @@ pub fn snapshot_csv(
let mut snapshot = InstanceSnapshot::new()
.name(name)
.class_name("LocalizationTable")
.properties(hashmap! {
"Contents".to_owned() => table_contents.into(),
})
.properties([("Contents".to_owned(), table_contents.into())])
.metadata(
InstanceMetadata::new()
.instigating_source(path)
Expand Down
5 changes: 1 addition & 4 deletions src/snapshot_middleware/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ pub fn snapshot_dir_no_meta(
mod test {
use super::*;

use maplit::hashmap;
use memofs::{InMemoryFs, VfsSnapshot};

#[test]
Expand All @@ -132,9 +131,7 @@ mod test {
let mut imfs = InMemoryFs::new();
imfs.load_snapshot(
"/foo",
VfsSnapshot::dir(hashmap! {
"Child" => VfsSnapshot::empty_dir(),
}),
VfsSnapshot::dir([("Child", VfsSnapshot::empty_dir())]),
)
.unwrap();

Expand Down
5 changes: 1 addition & 4 deletions src/snapshot_middleware/json.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::path::Path;

use anyhow::Context;
use maplit::hashmap;
use memofs::{IoResultExt, Vfs};

use crate::{
Expand All @@ -24,9 +23,7 @@ pub fn snapshot_json(

let as_lua = json_to_lua(value).to_string();

let properties = hashmap! {
"Source".to_owned() => as_lua.into(),
};
let properties = [("Source".to_owned(), as_lua.into())];

let meta_path = path.with_file_name(format!("{}.meta.json", name));

Expand Down
5 changes: 1 addition & 4 deletions src/snapshot_middleware/lua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ pub fn snapshot_lua_init(
mod test {
use super::*;

use maplit::hashmap;
use memofs::{InMemoryFs, VfsSnapshot};

#[test]
Expand Down Expand Up @@ -263,9 +262,7 @@ mod test {
let mut imfs = InMemoryFs::new();
imfs.load_snapshot(
"/root",
VfsSnapshot::dir(hashmap! {
"init.lua" => VfsSnapshot::file("Hello!"),
}),
VfsSnapshot::dir([("init.lua", VfsSnapshot::file("Hello!"))]),
)
.unwrap();

Expand Down
Loading
Loading