Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion crates/oxc_ast/src/ast_builder_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::{borrow::Cow, mem};

use oxc_allocator::{Allocator, Box, FromIn, IntoIn, Vec};
use oxc_allocator::{Allocator, Box, FromIn, IntoIn, String, Vec};
use oxc_span::{Atom, SPAN, Span};
use oxc_syntax::{number::NumberBase, operator::UnaryOperator, scope::ScopeId};

Expand Down Expand Up @@ -80,6 +80,13 @@ impl<'a> AstBuilder<'a> {
Atom::from_in(value, self.allocator)
}

/// Allocate an [`Atom`] from an array of string slices.
#[inline]
pub fn atom_from_strs_array<const N: usize>(self, array: [&str; N]) -> Atom<'a> {
let string = String::from_strs_array_in(array, self.allocator);
Atom::from(string)
}

/// Convert a [`Cow<'a, str>`] to an [`Atom<'a>`].
///
/// If the `Cow` borrows a string from arena, returns an `Atom` which references that same string,
Expand Down
Loading