Skip to content

Conversation

ranile
Copy link
Member

@ranile ranile commented Aug 27, 2022

This PR adds:

  • IString::as_cow
  • impl From<Cow<'static, str>> for IString

ranile added 4 commits August 27, 2022 23:17
This is helpful in cases like passing the IString to a function which takes a Cow without needing to clone the content
@ranile
Copy link
Member Author

ranile commented Aug 27, 2022

The Clippy failure is unrelated. It's likely that the derived implementation of PartialEq that clippy is highlighting is wrong

Copy link
Contributor

@cecton cecton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just seeing this now but it's nice! You should have ping me.

You can disable the lint for the impl of Eq at crate level I think it's not relevant here. We don't want to enforce the user to implement Eq on all their types otherwise they won't be able to store f32 and f64 in an IArray

assert_eq!(Rc::strong_count(&rc_s), 2);
// this assert exists to ensure the cow lives after the strong_count asset
assert_eq!(cow, "foo");

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines +84 to +91
impl From<Cow<'static, str>> for IString {
fn from(cow: Cow<'static, str>) -> Self {
match cow {
Cow::Borrowed(s) => IString::Static(s),
Cow::Owned(s) => s.into(),
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you forgot to write a test for this. It's not super important but it makes sure that someone does not remove it by mistake

@ranile
Copy link
Member Author

ranile commented Nov 30, 2022

I'm going to merge this. The test can be added later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants