pub fn with_nested<R, F: FnOnce(Option<&mut GasMeter<T>>) -> R>(
		&mut self,
		amount: T::Gas,
		f: F,
	) -> R {
		// NOTE that it is ok to allocate all available gas since it still ensured
		// by `charge` that it doesn't reach zero.
		if self.gas_left < amount {
			f(None)
		} else {
			self.gas_left = self.gas_left - amount;
			let mut nested = GasMeter {
				limit: amount,
				gas_left: amount,
				gas_price: self.gas_price,
				#[cfg(test)]
				tokens: Vec::new(),
			};

			let r = f(Some(&mut nested));

			self.gas_left = self.gas_left + nested.gas_left;

			r
		}
	}
/// Allocate some amount of gas and perform some work with
/// a newly created nested gas meter.
///
/// Invokes `f` with either the gas meter that has `amount` gas left or
/// with `None`, if this gas meter has not enough gas to allocate given `amount`.
///
/// All unused gas in the nested gas meter is returned to this gas meter.
Allocate some amount of gas and perform some work with
a newly created nested gas meter.



All unused gas in the nested gas meter is returned to this gas meter.
Allocate some amount of gas and perform some work with a newly created nested gas meter . All unused gas in the nested gas meter is returned to this gas meter .
pub fn with_nested<R, F: FnOnce(Option<&mut GasMeter<T>>) -> R>(
		&mut self,
		amount: T::Gas,
		f: F,
	) -> R {
		// NOTE that it is ok to allocate all available gas since it still ensured
		// by `charge` that it doesn't reach zero.
		if self.gas_left < amount {
			f(None)
		} else {
			self.gas_left = self.gas_left - amount;
			let mut nested = GasMeter {
				limit: amount,
				gas_left: amount,
				gas_price: self.gas_price,
				#[cfg(test)]
				tokens: Vec::new(),
			};
			let r = f(Some(&mut nested));
			self.gas_left = self.gas_left + nested.gas_left;
			r
		}
	}
pub fn with_nested < R , F : FnOnce ( Option < & mut GasMeter < T > > ) -> R > ( & mut self , amount : T :: Gas , f : F , ) -> R { // NOTE that it is ok to allocate all available gas since it still ensured // by `charge` that it doesn't reach zero. if self . gas_left < amount { f ( None ) } else { self . gas_left = self . gas_left - amount ; let mut nested = GasMeter { limit : amount , gas_left : amount , gas_price : self . gas_price , # [ cfg ( test ) ] tokens : Vec :: new ( ) , } ; let r = f ( Some ( & mut nested ) ) ; self . gas_left = self . gas_left + nested . gas_left ; r } }
Allocate some amount of gas and perform some work with
a newly created nested gas meter.
Allocate some amount of gas and perform some work with a newly created nested gas meter .
&mut self
amount
T::Gas
f
F
&mut self
amount
T::Gas
f
F