Skip to content

Commit

Permalink
Add impl From<CollectionId> for CollectionPath
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Dec 20, 2023
1 parent b7af41a commit 3b0bae8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/collection_path.rs
Expand Up @@ -124,6 +124,12 @@ impl CollectionPath {
}
}

impl std::convert::From<CollectionId> for CollectionPath {
fn from(collection_id: CollectionId) -> Self {
CollectionPath::new(None, collection_id)
}
}

impl std::convert::From<CollectionPath> for CollectionId {
fn from(collection_path: CollectionPath) -> Self {
collection_path.collection_id
Expand Down Expand Up @@ -246,6 +252,16 @@ mod tests {
Ok(())
}

#[test]
fn test_impl_from_collection_id_for_collection_path() -> anyhow::Result<()> {
let collection_id = CollectionId::from_str("chatrooms")?;
assert_eq!(
CollectionPath::from(collection_id),
CollectionPath::from_str("chatrooms")?
);
Ok(())
}

#[test]
fn test_impl_from_collection_path_for_collection_id() -> anyhow::Result<()> {
let collection_path = CollectionPath::from_str("chatrooms")?;
Expand Down

0 comments on commit 3b0bae8

Please sign in to comment.