difftreelog
refactor drop CharArray
in: master
5 files changed
crates/jrsonnet-evaluator/src/arr/mod.rsdiffbeforeafterboth45 Some(Self::new(RepeatedArray::new(data, repeats)?))45 Some(Self::new(RepeatedArray::new(data, repeats)?))46 }46 }4748 pub fn chars(chars: impl Iterator<Item = char>) -> Self {49 Self::new(CharArray(chars.collect()))50 }514752 #[must_use]48 #[must_use]53 pub fn map(self, mapper: NativeFn!((Val) -> Val)) -> Self {49 pub fn map(self, mapper: NativeFn!((Val) -> Val)) -> Self {crates/jrsonnet-evaluator/src/arr/spec.rsdiffbeforeafterboth97 }97 }98}98}99100#[derive(Trace, Debug)]101pub struct CharArray(pub Vec<char>);102impl ArrayCheap for CharArray {103 fn len(&self) -> usize {104 self.0.as_slice().len()105 }106 fn get(&self, index: usize) -> Option<Val> {107 self.0.as_slice().get(index).map(|v| Val::string(*v))108 }109}11099111impl ArrayCheap for IBytes {100impl ArrayCheap for IBytes {112 fn len(&self) -> usize {101 fn len(&self) -> usize {crates/jrsonnet-evaluator/src/typed/conversions.rsdiffbeforeafterboth463impl Typed for char {463impl Typed for char {464 const TYPE: &'static ComplexValType = &ComplexValType::Char;464 const TYPE: &'static ComplexValType = &ComplexValType::Char;465}465}466impl IntoUntyped for &char {467 fn into_untyped(value: Self) -> Result<Val> {468 Ok(Val::string(*value))469 }470}466impl IntoUntyped for char {471impl IntoUntyped for char {467 fn into_untyped(value: Self) -> Result<Val> {472 fn into_untyped(value: Self) -> Result<Val> {468 Ok(Val::string(value))473 Ok(Val::string(value))crates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth266266267 pub fn to_array(self) -> ArrValue {267 pub fn to_array(self) -> ArrValue {268 match self {268 match self {269 Self::Str(s) => ArrValue::chars(s.chars()),269 Self::Str(s) => s.chars().collect(),270 Self::Arr(arr) => arr,270 Self::Arr(arr) => arr,271 }271 }272 }272 }crates/jrsonnet-stdlib/src/strings.rsdiffbeforeafterboth223223224#[builtin]224#[builtin]225pub fn builtin_string_chars(str: IStr) -> ArrValue {225pub fn builtin_string_chars(str: IStr) -> ArrValue {226 ArrValue::chars(str.chars())226 str.chars().collect()227}227}228228229#[builtin]229#[builtin]