diff --git a/crates/oxc_ast/src/ast_builder_impl.rs b/crates/oxc_ast/src/ast_builder_impl.rs index bfc55fe74f921..d8d388e62dab1 100644 --- a/crates/oxc_ast/src/ast_builder_impl.rs +++ b/crates/oxc_ast/src/ast_builder_impl.rs @@ -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}; @@ -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(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,