Skip to content

Commit

Permalink
Version v0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
savannstm committed Aug 22, 2024
1 parent f39af5e commit c1352e5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "marshal-rs"
version = "0.2.0"
version = "0.2.1"
authors = ["savannstm <[email protected]>"]
edition = "2021"
rust-version = "1.63.0"
Expand Down
6 changes: 6 additions & 0 deletions src/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ impl<'a> Dumper<'a> {

if object_length > 0 {
for (key, value) in object.iter_mut() {
let mut key = key.to_owned();

if let Some(prefix) = self.instance_var_prefix {
key.replace_range(10..10 + prefix.len(), "@");
}

let key_string: String =
key.replacen(self.instance_var_prefix.unwrap_or("@"), "@", 1);

Expand Down
15 changes: 7 additions & 8 deletions src/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,13 @@ impl<'a> Loader<'a> {
let key: Value = unsafe { &*self.read_next().borrow().get() }.clone();
let value: Value = unsafe { &*self.read_next().borrow().get() }.clone();

let key_str: &str = key.as_str().unwrap();
rc.borrow_mut().get_mut()[key_str
.replacen(
"__symbol__@",
self.instance_var_prefix.unwrap_or("__symbol__@"),
1,
)
.as_str()] = value;
let mut key_str: String = key.as_str().unwrap().to_string();

if let Some(prefix) = self.instance_var_prefix {
key_str.replace_range(10..11, prefix)
}

rc.borrow_mut().get_mut()[key_str] = value;
}

rc
Expand Down

0 comments on commit c1352e5

Please sign in to comment.