Skip to content

Commit

Permalink
Make entity path parsing infallible by default
Browse files Browse the repository at this point in the history
Closes #3393

For the Python and Rust SDK, any string is now a valid entity path,
though perhaps not the one you where expecting. A warning is printed
if the format is not the normalized format.

For C/C++ I opted to still use the strict parsing for now.
We can revisit that later.
  • Loading branch information
emilk committed Sep 25, 2023
1 parent e4e1ae7 commit 435c006
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 148 deletions.
2 changes: 1 addition & 1 deletion crates/re_data_store/src/instance_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fn test_parse_instance_path() {
assert_eq!(
InstancePath::from_str("world/points[#123]"),
Ok(InstancePath {
entity_path: EntityPath::from_str("world/points").unwrap(),
entity_path: EntityPath::from("world/points"),
instance_key: InstanceKey(123)
})
);
Expand Down
6 changes: 2 additions & 4 deletions crates/re_log_types/src/path/entity_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,19 +210,17 @@ impl From<&[EntityPathPart]> for EntityPath {
}
}

#[allow(clippy::fallible_impl_from)] // TODO(#3393): we should force users to handle errors instead, and have a nice macro for constructing entity path
impl From<&str> for EntityPath {
#[inline]
fn from(path: &str) -> Self {
path.parse().unwrap()
EntityPath::parse_forgiving(path)
}
}

#[allow(clippy::fallible_impl_from)] // TODO(#3393): we should force users to handle errors instead, and have a nice macro for constructing entity path
impl From<String> for EntityPath {
#[inline]
fn from(path: String) -> Self {
path.parse().unwrap()
EntityPath::parse_forgiving(&path)
}
}

Expand Down
Loading

0 comments on commit 435c006

Please sign in to comment.