Skip to content

Commit

Permalink
deprecate from_str, renamed to from_ref
Browse files Browse the repository at this point in the history
  • Loading branch information
pchampin committed Sep 13, 2024
1 parent 1dddc9f commit f9b8667
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ const LEN_MASK: usize = usize::MAX >> 1;
const OWN_FLAG: usize = !LEN_MASK;

impl<'a> MownStr<'a> {
#[deprecated = "use from_ref instead. This method caused confusion with FromStr::from_str."]
pub const fn from_str(other: &'a str) -> MownStr<'a> {
Self::from_ref(other)
}

pub const fn from_ref(other: &'a str) -> MownStr<'a> {
assert!(other.len() <= LEN_MASK);
// NB: The only 'const' constructor for NonNull is new_unchecked
// so we need an unsafe block.
Expand Down Expand Up @@ -135,7 +140,7 @@ impl<'a> Clone for MownStr<'a> {

impl<'a> From<&'a str> for MownStr<'a> {
fn from(other: &'a str) -> MownStr<'a> {
Self::from_str(other)
Self::from_ref(other)
}
}

Expand Down

0 comments on commit f9b8667

Please sign in to comment.