Skip to content

Commit

Permalink
Use split_last
Browse files Browse the repository at this point in the history
  • Loading branch information
c-thiel committed Sep 23, 2024
1 parent e8eeb9a commit 0a45845
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions crates/iceberg/src/catalog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ impl NamespaceIdent {
/// Get the parent of this namespace.
/// Returns None if this namespace only has a single element and thus has no parent.
pub fn parent(&self) -> Option<Self> {
if self.0.len() <= 1 {
None
} else {
Some(Self(self.0[..self.0.len() - 1].to_vec()))
}
self.0.split_last().and_then(|(_, parent)| {
if parent.is_empty() {
None
} else {
Some(Self(parent.to_vec()))
}
})
}
}

Expand Down

0 comments on commit 0a45845

Please sign in to comment.