ArcStr now implements From<&str>.

This commit is contained in:
Filipe Rodrigues 2025-10-06 18:50:08 +01:00
parent 5a2c251b9b
commit 5176d20ab7
Signed by: zenithsiz
SSH Key Fingerprint: SHA256:Mb5ppb3Sh7IarBO/sBTXLHbYEOz37hJAlslLQPPAPaU
2 changed files with 7 additions and 1 deletions

View File

@ -812,7 +812,7 @@ mod tests {
];
for (input, expected_ast) in cases {
let mut parser = Parser::new(ArcStr::from(input.to_owned()));
let mut parser = Parser::new(input.into());
let ast = Ast::parse_from(&mut parser)
.unwrap_or_else(|err| panic!("Unable to parse input {input:?}: {}", err.pretty()));
assert_eq!(ast, expected_ast, "Ast differed for {input:?}");

View File

@ -163,6 +163,12 @@ impl Borrow<str> for ArcStr {
}
}
impl From<&'_ str> for ArcStr {
fn from(s: &str) -> Self {
Self::from(s.to_owned())
}
}
impl From<String> for ArcStr {
fn from(s: String) -> Self {
Self::from(Arc::new(s))