Utility method
parent
a67b7e89fc
commit
3d59ffffef
|
@ -12,6 +12,7 @@ use rhai::ImmutableString;
|
|||
use serde::{Deserialize, Deserializer};
|
||||
use smartstring::{LazyCompact, SmartString};
|
||||
use std::{
|
||||
borrow::Borrow,
|
||||
collections::HashMap,
|
||||
fmt::Display,
|
||||
fs::File,
|
||||
|
@ -130,7 +131,20 @@ pub struct ContentIndex(Arc<SmartString<LazyCompact>>);
|
|||
|
||||
impl From<ImmutableString> for ContentIndex {
|
||||
fn from(value: ImmutableString) -> Self {
|
||||
Self::new(&value)
|
||||
Self(Arc::new(value.into()))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ContentIndex> for ImmutableString {
|
||||
fn from(value: ContentIndex) -> Self {
|
||||
ImmutableString::from(Arc::into_inner(value.0).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&ContentIndex> for ImmutableString {
|
||||
fn from(value: &ContentIndex) -> Self {
|
||||
let x: &SmartString<LazyCompact> = value.0.borrow();
|
||||
ImmutableString::from(x.clone())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue