aboutsummaryrefslogtreecommitdiffstats
path: root/src/document
diff options
context:
space:
mode:
Diffstat (limited to 'src/document')
-rw-r--r--src/document/store.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/document/store.rs b/src/document/store.rs
index b343a2e..2e27b44 100644
--- a/src/document/store.rs
+++ b/src/document/store.rs
@@ -650,16 +650,15 @@ fn summary(
Ok(JsonValue::Object(out))
}
-/// Whether `path` holds a map (one, or concurrent ones merged).
-pub(crate) fn is_map(doc: &impl ReadDoc, path: &[String]) -> bool {
- matches!(resolve_through(doc, path), Ok(Some(Resolved::Maps(_))))
-}
-
-/// Keys of the merged map at `path`; empty if it doesn't exist or isn't a map.
-pub(crate) fn keys_at(doc: &impl ReadDoc, path: &[String]) -> Result<Vec<String>, StoreError> {
+/// Keys of the merged map at `path`; None if there is no map there (nothing, or
+/// another value).
+pub(crate) fn keys_at(
+ doc: &impl ReadDoc,
+ path: &[String],
+) -> Result<Option<Vec<String>>, StoreError> {
Ok(match resolve_through(doc, path)? {
- Some(Resolved::Maps(maps)) => merged_keys(doc, &maps).into_iter().collect(),
- _ => Vec::new(),
+ Some(Resolved::Maps(maps)) => Some(merged_keys(doc, &maps).into_iter().collect()),
+ _ => None,
})
}