aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/json
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-25 13:32:48 +0900
committernsfisis <nsfisis@gmail.com>2026-06-25 23:47:47 +0900
commit8d6b521e0034d1bcba594921ebc4f74e87e5ef46 (patch)
tree7207c9a7a7cbd1304171a013e0b7e8d38ecc4969 /crates/shirabe/src/json
parent285ce0831fdb617916cac6249dd36c56802e5598 (diff)
downloadphp-shirabe-8d6b521e0034d1bcba594921ebc4f74e87e5ef46.tar.gz
php-shirabe-8d6b521e0034d1bcba594921ebc4f74e87e5ef46.tar.zst
php-shirabe-8d6b521e0034d1bcba594921ebc4f74e87e5ef46.zip
style(json): apply rustfmt formatting
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/json')
-rw-r--r--crates/shirabe/src/json/json_grammar.rs10
-rw-r--r--crates/shirabe/src/json/json_manipulator.rs12
2 files changed, 17 insertions, 5 deletions
diff --git a/crates/shirabe/src/json/json_grammar.rs b/crates/shirabe/src/json/json_grammar.rs
index ce7ce86..bac235c 100644
--- a/crates/shirabe/src/json/json_grammar.rs
+++ b/crates/shirabe/src/json/json_grammar.rs
@@ -293,7 +293,10 @@ mod tests {
assert!(full(scan_value, "[]"));
assert!(full(scan_value, r#"{"a": 1, "b": [true, null]}"#));
assert!(full(scan_value, "{}"));
- assert!(full(scan_value, "{\n \"a\": {\n \"b\": \"c\"\n }\n}"));
+ assert!(full(
+ scan_value,
+ "{\n \"a\": {\n \"b\": \"c\"\n }\n}"
+ ));
assert_eq!(scan_value(br#"{"a": }"#, 0), None); // missing value
assert_eq!(scan_value(br#"{"a" 1}"#, 0), None); // missing colon
}
@@ -309,7 +312,10 @@ mod tests {
let c = "{\n \"foo\": \"bar\",\n \"require\": {\n \"a\": \"1\"\n }\n}";
let m = find_top_level_key(c.as_bytes(), br#""require""#, ValueKind::Object).unwrap();
assert_eq!(&c[m.key_pos..m.value_pos], "\"require\": ");
- assert_eq!(&c[m.value_pos..m.value_end], "{\n \"a\": \"1\"\n }");
+ assert_eq!(
+ &c[m.value_pos..m.value_end],
+ "{\n \"a\": \"1\"\n }"
+ );
// first key
let m2 = find_top_level_key(c.as_bytes(), br#""foo""#, ValueKind::Json).unwrap();
assert_eq!(&c[m2.value_pos..m2.value_end], "\"bar\"");
diff --git a/crates/shirabe/src/json/json_manipulator.rs b/crates/shirabe/src/json/json_manipulator.rs
index 50adcbc..71530d4 100644
--- a/crates/shirabe/src/json/json_manipulator.rs
+++ b/crates/shirabe/src/json/json_manipulator.rs
@@ -386,7 +386,12 @@ impl JsonManipulator {
let obj = self.contents[reps.value_pos..reps.value_end].to_string();
let key = JsonFile::encode(&repository_index);
json_grammar::find_top_level_key(obj.as_bytes(), key.as_bytes(), ValueKind::Object)
- .map(|inner| (reps.value_pos + inner.value_pos, reps.value_pos + inner.value_end))
+ .map(|inner| {
+ (
+ reps.value_pos + inner.value_pos,
+ reps.value_pos + inner.value_end,
+ )
+ })
})
};
@@ -1436,8 +1441,9 @@ impl JsonManipulator {
// Match the key only when its value is an empty object `{ <space> }`.
let encoded_key = JsonFile::encode(key);
let cb = self.contents.as_bytes();
- let key_match = json_grammar::find_top_level_key(cb, encoded_key.as_bytes(), ValueKind::Object)
- .filter(|m| json_grammar::skip_ws(cb, m.value_pos + 1) == m.value_end - 1);
+ let key_match =
+ json_grammar::find_top_level_key(cb, encoded_key.as_bytes(), ValueKind::Object)
+ .filter(|m| json_grammar::skip_ws(cb, m.value_pos + 1) == m.value_end - 1);
if let Some(m) = key_match {
// invalid match due to un-regexable content, abort
let removal = &self.contents[m.value_pos..m.value_end];