fn range<'a>(
        &'a self,
        start: Option<&[u8]>,
        end: Option<&[u8]>,
        order: Order,
    ) -> FfiResult<Box<dyn StorageIterator + 'a>> {
        let gas_info = GasInfo::with_externally_used(GAS_COST_RANGE);
        let bounds = range_bounds(start, end);

        // BTreeMap.range panics if range is start > end.
        // However, this cases represent just empty range and we treat it as such.
        match (bounds.start_bound(), bounds.end_bound()) {
            (Bound::Included(start), Bound::Excluded(end)) if start > end => {
                return (Ok(Box::new(MockIterator::empty())), gas_info);
            }
            _ => {}
        }

        let original_iter = self.data.range(bounds);
        let iter: Box<dyn Iterator<Item = (KV, u64)>> = match order {
            Order::Ascending => Box::new(original_iter.map(clone_item).map(|item| {
                let gas_cost = (item.0.len() + item.1.len()) as u64;
                (item, gas_cost)
            })),
            Order::Descending => Box::new(original_iter.rev().map(clone_item).map(|item| {
                let gas_cost = (item.0.len() + item.1.len()) as u64;
                (item, gas_cost)
            })),
        };
        (Ok(Box::new(MockIterator { source: iter })), gas_info)
    }
/// range allows iteration over a set of keys, either forwards or backwards
/// uses standard rust range notation, and eg db.range(b"foo"..b"bar") also works reverse
range allows iteration over a set of keys, either forwards or backwards
uses standard rust range notation, and eg db.range(b"foo"..b"bar") also works reverse
range allows iteration over a set of keys either forwards or backwards uses standard rust range notation and eg db . range ( b " foo " .. b " bar " ) also works reverse
fn range<'a>(
        &'a self,
        start: Option<&[u8]>,
        end: Option<&[u8]>,
        order: Order,
    ) -> FfiResult<Box<dyn StorageIterator + 'a>> {
        let gas_info = GasInfo::with_externally_used(GAS_COST_RANGE);
        let bounds = range_bounds(start, end);
        // BTreeMap.range panics if range is start > end.
        // However, this cases represent just empty range and we treat it as such.
        match (bounds.start_bound(), bounds.end_bound()) {
            (Bound::Included(start), Bound::Excluded(end)) if start > end => {
                return (Ok(Box::new(MockIterator::empty())), gas_info);
            }
            _ => {}
        }
        let original_iter = self.data.range(bounds);
        let iter: Box<dyn Iterator<Item = (KV, u64)>> = match order {
            Order::Ascending => Box::new(original_iter.map(clone_item).map(|item| {
                let gas_cost = (item.0.len() + item.1.len()) as u64;
                (item, gas_cost)
            })),
            Order::Descending => Box::new(original_iter.rev().map(clone_item).map(|item| {
                let gas_cost = (item.0.len() + item.1.len()) as u64;
                (item, gas_cost)
            })),
        };
        (Ok(Box::new(MockIterator { source: iter })), gas_info)
    }
fn range < ' a > ( & ' a self , start : Option < & [ u8 ] > , end : Option < & [ u8 ] > , order : Order , ) -> FfiResult < Box < dyn StorageIterator + ' a > > { let gas_info = GasInfo :: with_externally_used ( GAS_COST_RANGE ) ; let bounds = range_bounds ( start , end ) ; // BTreeMap.range panics if range is start > end. // However, this cases represent just empty range and we treat it as such. match ( bounds . start_bound ( ) , bounds . end_bound ( ) ) { ( Bound :: Included ( start ) , Bound :: Excluded ( end ) ) if start > end => { return ( Ok ( Box :: new ( MockIterator :: empty ( ) ) ) , gas_info ) ; } _ => { } } let original_iter = self . data . range ( bounds ) ; let iter : Box < dyn Iterator < Item = ( KV , u64 ) > > = match order { Order :: Ascending => Box :: new ( original_iter . map ( clone_item ) . map ( | item | { let gas_cost = ( item . 0 . len ( ) + item . 1 . len ( ) ) as u64 ; ( item , gas_cost ) } ) ) , Order :: Descending => Box :: new ( original_iter . rev ( ) . map ( clone_item ) . map ( | item | { let gas_cost = ( item . 0 . len ( ) + item . 1 . len ( ) ) as u64 ; ( item , gas_cost ) } ) ) , } ; ( Ok ( Box :: new ( MockIterator { source : iter } ) ) , gas_info ) }
range allows iteration over a set of keys, either forwards or backwards
uses standard rust range notation, and eg db.range(b"foo"..b"bar") also works reverse
range allows iteration over a set of keys either forwards or backwards uses standard rust range notation and eg db . range ( b " foo " .. b " bar " ) also works reverse
&'a self
start
Option<&[u8]>
end
Option<&[u8]>
order
Order
&'a self
start
Option<&[u8]>
end
Option<&[u8]>
order
Order