git.delta.rocks / jrsonnet / refs/commits / 4944c9eb9e42

difftreelog

refactor drop CharArray

rzmtutyqYaroslav Bolyukin2026-04-04parent: #6f6b79f.patch.diff
in: master

5 files changed

modifiedcrates/jrsonnet-evaluator/src/arr/mod.rsdiffbeforeafterboth
45 Some(Self::new(RepeatedArray::new(data, repeats)?))45 Some(Self::new(RepeatedArray::new(data, repeats)?))
46 }46 }
47
48 pub fn chars(chars: impl Iterator<Item = char>) -> Self {
49 Self::new(CharArray(chars.collect()))
50 }
5147
52 #[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 {
modifiedcrates/jrsonnet-evaluator/src/arr/spec.rsdiffbeforeafterboth
97 }97 }
98}98}
99
100#[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}
11099
111impl ArrayCheap for IBytes {100impl ArrayCheap for IBytes {
112 fn len(&self) -> usize {101 fn len(&self) -> usize {
modifiedcrates/jrsonnet-evaluator/src/typed/conversions.rsdiffbeforeafterboth
463impl 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))
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
266266
267 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 }
modifiedcrates/jrsonnet-stdlib/src/strings.rsdiffbeforeafterboth
223223
224#[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}
228228
229#[builtin]229#[builtin]