Skip to content

Commit

Permalink
refactor(span): clarify Atom conversion methods lifetimes (#4978)
Browse files Browse the repository at this point in the history
Rename lifetimes on `FromIn` impls for `Atom`s to make it clear where the lifetime of the `Atom` comes from the allocator's lifetime.
  • Loading branch information
overlookmotel committed Aug 19, 2024
1 parent 4012260 commit 7706523
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions crates/oxc_span/src/atom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,32 +67,32 @@ impl<'old_alloc, 'new_alloc> CloneIn<'new_alloc> for Atom<'old_alloc> {
}
}

impl<'a, 'b> FromIn<'a, &'b Atom<'a>> for Atom<'a> {
fn from_in(s: &'b Atom<'a>, _: &'a Allocator) -> Self {
impl<'alloc> FromIn<'alloc, &Atom<'alloc>> for Atom<'alloc> {
fn from_in(s: &Atom<'alloc>, _: &'alloc Allocator) -> Self {
Self::from(s.0)
}
}

impl<'a, 'b> FromIn<'a, &'b str> for Atom<'a> {
fn from_in(s: &'b str, allocator: &'a Allocator) -> Self {
impl<'alloc> FromIn<'alloc, &str> for Atom<'alloc> {
fn from_in(s: &str, allocator: &'alloc Allocator) -> Self {
Self::from(oxc_allocator::String::from_str_in(s, allocator).into_bump_str())
}
}

impl<'a> FromIn<'a, String> for Atom<'a> {
fn from_in(s: String, allocator: &'a Allocator) -> Self {
impl<'alloc> FromIn<'alloc, String> for Atom<'alloc> {
fn from_in(s: String, allocator: &'alloc Allocator) -> Self {
Self::from_in(s.as_str(), allocator)
}
}

impl<'a> FromIn<'a, &String> for Atom<'a> {
fn from_in(s: &String, allocator: &'a Allocator) -> Self {
impl<'alloc> FromIn<'alloc, &String> for Atom<'alloc> {
fn from_in(s: &String, allocator: &'alloc Allocator) -> Self {
Self::from_in(s.as_str(), allocator)
}
}

impl<'a, 'b> FromIn<'a, Cow<'b, str>> for Atom<'a> {
fn from_in(s: Cow<'b, str>, allocator: &'a Allocator) -> Self {
impl<'alloc> FromIn<'alloc, Cow<'_, str>> for Atom<'alloc> {
fn from_in(s: Cow<'_, str>, allocator: &'alloc Allocator) -> Self {
Self::from_in(&*s, allocator)
}
}
Expand Down

0 comments on commit 7706523

Please sign in to comment.