difftreelog
refactor consistent *32 method naming
in: master
1 file changed
crates/jrsonnet-evaluator/src/arr/spec.rsdiffbeforeafterboth34 }34 }35}35}36trait ArrayCheap {36trait ArrayCheap {37 fn get(&self, index: u32) -> Option<Val>;37 fn get32(&self, index: u32) -> Option<Val>;38 fn len(&self) -> u32;38 fn len32(&self) -> u32;39}39}40impl<T> ArrayLike for T40impl<T> ArrayLike for T41where41where42 T: Any + Trace + Debug + ArrayCheap,42 T: Any + Trace + Debug + ArrayCheap,43{43{44 fn len32(&self) -> u32 {44 fn len32(&self) -> u32 {45 <T as ArrayCheap>::len(self)45 <T as ArrayCheap>::len32(self)46 }46 }474748 fn get32(&self, index: u32) -> Result<Option<Val>> {48 fn get32(&self, index: u32) -> Result<Option<Val>> {49 Ok(<T as ArrayCheap>::get(self, index))49 Ok(<T as ArrayCheap>::get32(self, index))50 }50 }515152 fn get_lazy32(&self, index: u32) -> Option<Thunk<Val>> {52 fn get_lazy32(&self, index: u32) -> Option<Thunk<Val>> {53 <T as ArrayCheap>::get(self, index).map(Thunk::evaluated)53 <T as ArrayCheap>::get32(self, index).map(Thunk::evaluated)54 }54 }555556 fn is_cheap(&self) -> bool {56 fn is_cheap(&self) -> bool {59}59}606061impl ArrayCheap for () {61impl ArrayCheap for () {62 fn len(&self) -> u32 {62 fn len32(&self) -> u32 {63 063 064 }64 }65 fn get(&self, _index: u32) -> Option<Val> {65 fn get32(&self, _index: u32) -> Option<Val> {66 None66 None67 }67 }68}68}99}99}100100101impl ArrayCheap for IBytes {101impl ArrayCheap for IBytes {102 fn len(&self) -> u32 {102 fn len32(&self) -> u32 {103 arridx(self.as_slice().len())103 arridx(self.as_slice().len())104 }104 }105 fn get(&self, index: u32) -> Option<Val> {105 fn get32(&self, index: u32) -> Option<Val> {106 self.as_slice()106 self.as_slice()107 .get(index as usize)107 .get(index as usize)108 .map(|v| Val::Num((*v).into()))108 .map(|v| Val::Num((*v).into()))109 }109 }110}110}111111112impl ArrayCheap for Rc<Vec<TrivialVal>> {112impl ArrayCheap for Rc<Vec<TrivialVal>> {113 fn get(&self, index: u32) -> Option<Val> {113 fn get32(&self, index: u32) -> Option<Val> {114 self.as_slice()114 self.as_slice()115 .get(index as usize)115 .get(index as usize)116 .map(|tv| tv.clone().into())116 .map(|tv| tv.clone().into())117 }117 }118118119 fn len(&self) -> u32 {119 fn len32(&self) -> u32 {120 arridx(self.as_slice().len())120 arridx(self.as_slice().len())121 }121 }122}122}353 }353 }354}354}355impl ArrayCheap for RangeArray {355impl ArrayCheap for RangeArray {356 fn get(&self, index: u32) -> Option<Val> {356 fn get32(&self, index: u32) -> Option<Val> {357 self.range().nth(index as usize).map(|i| Val::Num(i.into()))357 self.range().nth(index as usize).map(|i| Val::Num(i.into()))358 }358 }359 fn len(&self) -> u32 {359 fn len32(&self) -> u32 {360 self.size()360 self.size()361 }361 }362}362}