summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfdb-hiroshima <35889323+fdb-hiroshima@users.noreply.github.com>2019-07-27 10:58:43 +0200
committerPaul Masurel <paul.masurel@gmail.com>2019-07-27 17:58:43 +0900
commitc91eb7fba73709a974ca8c7b91c7a429dae82118 (patch)
tree80f0e012c3d8167bfae1dc9b744b688e63e4b024
parent6eb4e08636f48091f7783d52c84ef78e7ff1ada4 (diff)
add to_path for Facet (#604)
fix #580
-rw-r--r--src/schema/facet.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/schema/facet.rs b/src/schema/facet.rs
index 4477982..a77146f 100644
--- a/src/schema/facet.rs
+++ b/src/schema/facet.rs
@@ -117,6 +117,13 @@ impl Facet {
&& other_str.starts_with(self_str)
&& other_str.as_bytes()[self_str.len()] == FACET_SEP_BYTE
}
+
+ /// Extract path from the `Facet`.
+ pub fn to_path(&self) -> Vec<&str> {
+ self.encoded_str()
+ .split(|c| c == FACET_SEP_CHAR)
+ .collect()
+ }
}
impl Borrow<str> for Facet {
@@ -254,4 +261,10 @@ mod tests {
assert_eq!(format!("{:?}", facet), "Facet(/first/second/third)");
}
+ #[test]
+ fn test_to_path() {
+ let v = ["first", "second", "third\\/not_fourth"];
+ let facet = Facet::from_path(v.iter());
+ assert_eq!(facet.to_path(), v);
+ }
}