Struct sp_weights::Weight
source · pub struct Weight { /* private fields */ }Implementations§
source§impl Weight
impl Weight
sourcepub const fn set_ref_time(self, c: u64) -> Self
pub const fn set_ref_time(self, c: u64) -> Self
Set the reference time part of the weight.
sourcepub const fn set_proof_size(self, c: u64) -> Self
pub const fn set_proof_size(self, c: u64) -> Self
Set the storage size part of the weight.
sourcepub const fn ref_time(&self) -> u64
pub const fn ref_time(&self) -> u64
Return the reference time part of the weight.
Examples found in repository?
More examples
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
fn weight_to_fee(weight: &Weight) -> Self::Balance {
Self::polynomial()
.iter()
.fold(Self::Balance::saturated_from(0u32), |mut acc, args| {
let w = Self::Balance::saturated_from(weight.ref_time())
.saturating_pow(args.degree.into());
// The sum could get negative. Therefore we only sum with the accumulator.
// The Perbill Mul implementation is non overflowing.
let frac = args.coeff_frac * w;
let integer = args.coeff_integer.saturating_mul(w);
if args.negative {
acc = acc.saturating_sub(frac);
acc = acc.saturating_sub(integer);
} else {
acc = acc.saturating_add(frac);
acc = acc.saturating_add(integer);
}
acc
})
}
}
/// Implementor of `WeightToFee` that maps one unit of weight to one unit of fee.
pub struct IdentityFee<T>(sp_std::marker::PhantomData<T>);
impl<T> WeightToFee for IdentityFee<T>
where
T: BaseArithmetic + From<u32> + Copy + Unsigned,
{
type Balance = T;
fn weight_to_fee(weight: &Weight) -> Self::Balance {
Self::Balance::saturated_from(weight.ref_time())
}
}
/// Implementor of [`WeightToFee`] that uses a constant multiplier.
/// # Example
///
/// ```
/// # use sp_core::ConstU128;
/// # use sp_weights::ConstantMultiplier;
/// // Results in a multiplier of 10 for each unit of weight (or length)
/// type LengthToFee = ConstantMultiplier::<u128, ConstU128<10u128>>;
/// ```
pub struct ConstantMultiplier<T, M>(sp_std::marker::PhantomData<(T, M)>);
impl<T, M> WeightToFee for ConstantMultiplier<T, M>
where
T: BaseArithmetic + From<u32> + Copy + Unsigned,
M: Get<T>,
{
type Balance = T;
fn weight_to_fee(weight: &Weight) -> Self::Balance {
Self::Balance::saturated_from(weight.ref_time()).saturating_mul(M::get())
}sourcepub const fn proof_size(&self) -> u64
pub const fn proof_size(&self) -> u64
Return the storage size part of the weight.
sourcepub fn ref_time_mut(&mut self) -> &mut u64
pub fn ref_time_mut(&mut self) -> &mut u64
Return a mutable reference to the reference time part of the weight.
sourcepub fn proof_size_mut(&mut self) -> &mut u64
pub fn proof_size_mut(&mut self) -> &mut u64
Return a mutable reference to the storage size part of the weight.
pub const MAX: Self = _
sourcepub fn try_add(&self, other: &Self, limit: &Self) -> Option<Self>
pub fn try_add(&self, other: &Self, limit: &Self) -> Option<Self>
Try to add some other weight while upholding the limit.
sourcepub const fn from_ref_time(ref_time: u64) -> Self
pub const fn from_ref_time(ref_time: u64) -> Self
Construct Weight with reference time weight and 0 storage size weight.
Examples found in repository?
More examples
91 92 93 94 95 96 97 98 99 100 101 102 103
pub fn reads(self, r: u64) -> Weight {
Weight::from_ref_time(self.read.saturating_mul(r))
}
pub fn writes(self, w: u64) -> Weight {
Weight::from_ref_time(self.write.saturating_mul(w))
}
pub fn reads_writes(self, r: u64, w: u64) -> Weight {
let read_weight = self.read.saturating_mul(r);
let write_weight = self.write.saturating_mul(w);
Weight::from_ref_time(read_weight.saturating_add(write_weight))
}sourcepub const fn from_proof_size(proof_size: u64) -> Self
pub const fn from_proof_size(proof_size: u64) -> Self
Construct Weight with storage size weight and 0 reference time weight.
sourcepub const fn from_parts(ref_time: u64, proof_size: u64) -> Self
pub const fn from_parts(ref_time: u64, proof_size: u64) -> Self
Construct Weight from weight parts, namely reference time and proof size weights.
sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
Saturating Weight addition. Computes self + rhs, saturating at the numeric bounds of
all fields instead of overflowing.
sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
Saturating Weight subtraction. Computes self - rhs, saturating at the numeric bounds
of all fields instead of overflowing.
sourcepub const fn saturating_mul(self, scalar: u64) -> Self
pub const fn saturating_mul(self, scalar: u64) -> Self
Saturating Weight scalar multiplication. Computes self.field * scalar for all fields,
saturating at the numeric bounds of all fields instead of overflowing.
sourcepub const fn saturating_div(self, scalar: u64) -> Self
pub const fn saturating_div(self, scalar: u64) -> Self
Saturating Weight scalar division. Computes self.field / scalar for all fields,
saturating at the numeric bounds of all fields instead of overflowing.
sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
Saturating Weight scalar exponentiation. Computes self.field.pow(exp) for all fields,
saturating at the numeric bounds of all fields instead of overflowing.
sourcepub fn saturating_accrue(&mut self, amount: Self)
pub fn saturating_accrue(&mut self, amount: Self)
Increment Weight by amount via saturating addition.
sourcepub const fn checked_add(&self, rhs: &Self) -> Option<Self>
pub const fn checked_add(&self, rhs: &Self) -> Option<Self>
Checked Weight addition. Computes self + rhs, returning None if overflow occurred.
Examples found in repository?
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
pub fn try_add(&self, other: &Self, limit: &Self) -> Option<Self> {
let total = self.checked_add(other)?;
if total.any_gt(*limit) {
None
} else {
Some(total)
}
}
/// Construct [`Weight`] with reference time weight and 0 storage size weight.
pub const fn from_ref_time(ref_time: u64) -> Self {
Self { ref_time, proof_size: 0 }
}
/// Construct [`Weight`] with storage size weight and 0 reference time weight.
pub const fn from_proof_size(proof_size: u64) -> Self {
Self { ref_time: 0, proof_size }
}
/// Construct [`Weight`] from weight parts, namely reference time and proof size weights.
pub const fn from_parts(ref_time: u64, proof_size: u64) -> Self {
Self { ref_time, proof_size }
}
/// Saturating [`Weight`] addition. Computes `self + rhs`, saturating at the numeric bounds of
/// all fields instead of overflowing.
pub const fn saturating_add(self, rhs: Self) -> Self {
Self {
ref_time: self.ref_time.saturating_add(rhs.ref_time),
proof_size: self.proof_size.saturating_add(rhs.proof_size),
}
}
/// Saturating [`Weight`] subtraction. Computes `self - rhs`, saturating at the numeric bounds
/// of all fields instead of overflowing.
pub const fn saturating_sub(self, rhs: Self) -> Self {
Self {
ref_time: self.ref_time.saturating_sub(rhs.ref_time),
proof_size: self.proof_size.saturating_sub(rhs.proof_size),
}
}
/// Saturating [`Weight`] scalar multiplication. Computes `self.field * scalar` for all fields,
/// saturating at the numeric bounds of all fields instead of overflowing.
pub const fn saturating_mul(self, scalar: u64) -> Self {
Self {
ref_time: self.ref_time.saturating_mul(scalar),
proof_size: self.proof_size.saturating_mul(scalar),
}
}
/// Saturating [`Weight`] scalar division. Computes `self.field / scalar` for all fields,
/// saturating at the numeric bounds of all fields instead of overflowing.
pub const fn saturating_div(self, scalar: u64) -> Self {
Self {
ref_time: self.ref_time.saturating_div(scalar),
proof_size: self.proof_size.saturating_div(scalar),
}
}
/// Saturating [`Weight`] scalar exponentiation. Computes `self.field.pow(exp)` for all fields,
/// saturating at the numeric bounds of all fields instead of overflowing.
pub const fn saturating_pow(self, exp: u32) -> Self {
Self {
ref_time: self.ref_time.saturating_pow(exp),
proof_size: self.proof_size.saturating_pow(exp),
}
}
/// Increment [`Weight`] by `amount` via saturating addition.
pub fn saturating_accrue(&mut self, amount: Self) {
*self = self.saturating_add(amount);
}
/// Checked [`Weight`] addition. Computes `self + rhs`, returning `None` if overflow occurred.
pub const fn checked_add(&self, rhs: &Self) -> Option<Self> {
let ref_time = match self.ref_time.checked_add(rhs.ref_time) {
Some(t) => t,
None => return None,
};
let proof_size = match self.proof_size.checked_add(rhs.proof_size) {
Some(s) => s,
None => return None,
};
Some(Self { ref_time, proof_size })
}
/// Checked [`Weight`] subtraction. Computes `self - rhs`, returning `None` if overflow
/// occurred.
pub const fn checked_sub(&self, rhs: &Self) -> Option<Self> {
let ref_time = match self.ref_time.checked_sub(rhs.ref_time) {
Some(t) => t,
None => return None,
};
let proof_size = match self.proof_size.checked_sub(rhs.proof_size) {
Some(s) => s,
None => return None,
};
Some(Self { ref_time, proof_size })
}
/// Checked [`Weight`] scalar multiplication. Computes `self.field * scalar` for each field,
/// returning `None` if overflow occurred.
pub const fn checked_mul(self, scalar: u64) -> Option<Self> {
let ref_time = match self.ref_time.checked_mul(scalar) {
Some(t) => t,
None => return None,
};
let proof_size = match self.proof_size.checked_mul(scalar) {
Some(s) => s,
None => return None,
};
Some(Self { ref_time, proof_size })
}
/// Checked [`Weight`] scalar division. Computes `self.field / scalar` for each field, returning
/// `None` if overflow occurred.
pub const fn checked_div(self, scalar: u64) -> Option<Self> {
let ref_time = match self.ref_time.checked_div(scalar) {
Some(t) => t,
None => return None,
};
let proof_size = match self.proof_size.checked_div(scalar) {
Some(s) => s,
None => return None,
};
Some(Self { ref_time, proof_size })
}
/// Return a [`Weight`] where all fields are zero.
pub const fn zero() -> Self {
Self { ref_time: 0, proof_size: 0 }
}
/// Constant version of Add with u64.
///
/// Is only overflow safe when evaluated at compile-time.
pub const fn add(self, scalar: u64) -> Self {
Self { ref_time: self.ref_time + scalar, proof_size: self.proof_size + scalar }
}
/// Constant version of Sub with u64.
///
/// Is only overflow safe when evaluated at compile-time.
pub const fn sub(self, scalar: u64) -> Self {
Self { ref_time: self.ref_time - scalar, proof_size: self.proof_size - scalar }
}
/// Constant version of Div with u64.
///
/// Is only overflow safe when evaluated at compile-time.
pub const fn div(self, scalar: u64) -> Self {
Self { ref_time: self.ref_time / scalar, proof_size: self.proof_size / scalar }
}
/// Constant version of Mul with u64.
///
/// Is only overflow safe when evaluated at compile-time.
pub const fn mul(self, scalar: u64) -> Self {
Self { ref_time: self.ref_time * scalar, proof_size: self.proof_size * scalar }
}
/// Returns true if any of `self`'s constituent weights is strictly greater than that of the
/// `other`'s, otherwise returns false.
pub const fn any_gt(self, other: Self) -> bool {
self.ref_time > other.ref_time || self.proof_size > other.proof_size
}
/// Returns true if all of `self`'s constituent weights is strictly greater than that of the
/// `other`'s, otherwise returns false.
pub const fn all_gt(self, other: Self) -> bool {
self.ref_time > other.ref_time && self.proof_size > other.proof_size
}
/// Returns true if any of `self`'s constituent weights is strictly less than that of the
/// `other`'s, otherwise returns false.
pub const fn any_lt(self, other: Self) -> bool {
self.ref_time < other.ref_time || self.proof_size < other.proof_size
}
/// Returns true if all of `self`'s constituent weights is strictly less than that of the
/// `other`'s, otherwise returns false.
pub const fn all_lt(self, other: Self) -> bool {
self.ref_time < other.ref_time && self.proof_size < other.proof_size
}
/// Returns true if any of `self`'s constituent weights is greater than or equal to that of the
/// `other`'s, otherwise returns false.
pub const fn any_gte(self, other: Self) -> bool {
self.ref_time >= other.ref_time || self.proof_size >= other.proof_size
}
/// Returns true if all of `self`'s constituent weights is greater than or equal to that of the
/// `other`'s, otherwise returns false.
pub const fn all_gte(self, other: Self) -> bool {
self.ref_time >= other.ref_time && self.proof_size >= other.proof_size
}
/// Returns true if any of `self`'s constituent weights is less than or equal to that of the
/// `other`'s, otherwise returns false.
pub const fn any_lte(self, other: Self) -> bool {
self.ref_time <= other.ref_time || self.proof_size <= other.proof_size
}
/// Returns true if all of `self`'s constituent weights is less than or equal to that of the
/// `other`'s, otherwise returns false.
pub const fn all_lte(self, other: Self) -> bool {
self.ref_time <= other.ref_time && self.proof_size <= other.proof_size
}
/// Returns true if any of `self`'s constituent weights is equal to that of the `other`'s,
/// otherwise returns false.
pub const fn any_eq(self, other: Self) -> bool {
self.ref_time == other.ref_time || self.proof_size == other.proof_size
}
// NOTE: `all_eq` does not exist, as it's simply the `eq` method from the `PartialEq` trait.
}
impl Zero for Weight {
fn zero() -> Self {
Self::zero()
}
fn is_zero(&self) -> bool {
self == &Self::zero()
}
}
impl Add for Weight {
type Output = Self;
fn add(self, rhs: Self) -> Self {
Self {
ref_time: self.ref_time + rhs.ref_time,
proof_size: self.proof_size + rhs.proof_size,
}
}
}
impl Sub for Weight {
type Output = Self;
fn sub(self, rhs: Self) -> Self {
Self {
ref_time: self.ref_time - rhs.ref_time,
proof_size: self.proof_size - rhs.proof_size,
}
}
}
impl<T> Mul<T> for Weight
where
T: Mul<u64, Output = u64> + Copy,
{
type Output = Self;
fn mul(self, b: T) -> Self {
Self { ref_time: b * self.ref_time, proof_size: b * self.proof_size }
}
}
macro_rules! weight_mul_per_impl {
($($t:ty),* $(,)?) => {
$(
impl Mul<Weight> for $t {
type Output = Weight;
fn mul(self, b: Weight) -> Weight {
Weight {
ref_time: self * b.ref_time,
proof_size: self * b.proof_size,
}
}
}
)*
}
}
weight_mul_per_impl!(
sp_arithmetic::Percent,
sp_arithmetic::PerU16,
sp_arithmetic::Permill,
sp_arithmetic::Perbill,
sp_arithmetic::Perquintill,
);
macro_rules! weight_mul_primitive_impl {
($($t:ty),* $(,)?) => {
$(
impl Mul<Weight> for $t {
type Output = Weight;
fn mul(self, b: Weight) -> Weight {
Weight {
ref_time: u64::from(self) * b.ref_time,
proof_size: u64::from(self) * b.proof_size,
}
}
}
)*
}
}
weight_mul_primitive_impl!(u8, u16, u32, u64);
impl<T> Div<T> for Weight
where
u64: Div<T, Output = u64>,
T: Copy,
{
type Output = Self;
fn div(self, b: T) -> Self {
Self { ref_time: self.ref_time / b, proof_size: self.proof_size / b }
}
}
impl CheckedAdd for Weight {
fn checked_add(&self, rhs: &Self) -> Option<Self> {
self.checked_add(rhs)
}More examples
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
pub fn check_accrue(&mut self, w: Weight) -> bool {
self.consumed.checked_add(&w).map_or(false, |test| {
if test.any_gt(self.limit) {
false
} else {
self.consumed = test;
true
}
})
}
/// Check if the given weight can be consumed.
pub fn can_accrue(&self, w: Weight) -> bool {
self.consumed.checked_add(&w).map_or(false, |t| t.all_lte(self.limit))
}sourcepub const fn checked_sub(&self, rhs: &Self) -> Option<Self>
pub const fn checked_sub(&self, rhs: &Self) -> Option<Self>
Checked Weight subtraction. Computes self - rhs, returning None if overflow
occurred.
sourcepub const fn checked_mul(self, scalar: u64) -> Option<Self>
pub const fn checked_mul(self, scalar: u64) -> Option<Self>
Checked Weight scalar multiplication. Computes self.field * scalar for each field,
returning None if overflow occurred.
sourcepub const fn checked_div(self, scalar: u64) -> Option<Self>
pub const fn checked_div(self, scalar: u64) -> Option<Self>
Checked Weight scalar division. Computes self.field / scalar for each field, returning
None if overflow occurred.
sourcepub const fn zero() -> Self
pub const fn zero() -> Self
Return a Weight where all fields are zero.
Examples found in repository?
More examples
sourcepub const fn add(self, scalar: u64) -> Self
pub const fn add(self, scalar: u64) -> Self
Constant version of Add with u64.
Is only overflow safe when evaluated at compile-time.
sourcepub const fn sub(self, scalar: u64) -> Self
pub const fn sub(self, scalar: u64) -> Self
Constant version of Sub with u64.
Is only overflow safe when evaluated at compile-time.
sourcepub const fn div(self, scalar: u64) -> Self
pub const fn div(self, scalar: u64) -> Self
Constant version of Div with u64.
Is only overflow safe when evaluated at compile-time.
sourcepub const fn mul(self, scalar: u64) -> Self
pub const fn mul(self, scalar: u64) -> Self
Constant version of Mul with u64.
Is only overflow safe when evaluated at compile-time.
sourcepub const fn any_gt(self, other: Self) -> bool
pub const fn any_gt(self, other: Self) -> bool
Returns true if any of self’s constituent weights is strictly greater than that of the
other’s, otherwise returns false.
Examples found in repository?
More examples
sourcepub const fn all_gt(self, other: Self) -> bool
pub const fn all_gt(self, other: Self) -> bool
Returns true if all of self’s constituent weights is strictly greater than that of the
other’s, otherwise returns false.
sourcepub const fn any_lt(self, other: Self) -> bool
pub const fn any_lt(self, other: Self) -> bool
Returns true if any of self’s constituent weights is strictly less than that of the
other’s, otherwise returns false.
sourcepub const fn all_lt(self, other: Self) -> bool
pub const fn all_lt(self, other: Self) -> bool
Returns true if all of self’s constituent weights is strictly less than that of the
other’s, otherwise returns false.
sourcepub const fn any_gte(self, other: Self) -> bool
pub const fn any_gte(self, other: Self) -> bool
Returns true if any of self’s constituent weights is greater than or equal to that of the
other’s, otherwise returns false.
sourcepub const fn all_gte(self, other: Self) -> bool
pub const fn all_gte(self, other: Self) -> bool
Returns true if all of self’s constituent weights is greater than or equal to that of the
other’s, otherwise returns false.
sourcepub const fn any_lte(self, other: Self) -> bool
pub const fn any_lte(self, other: Self) -> bool
Returns true if any of self’s constituent weights is less than or equal to that of the
other’s, otherwise returns false.
sourcepub const fn all_lte(self, other: Self) -> bool
pub const fn all_lte(self, other: Self) -> bool
Returns true if all of self’s constituent weights is less than or equal to that of the
other’s, otherwise returns false.
Examples found in repository?
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
pub fn defensive_saturating_accrue(&mut self, w: Weight) {
self.consumed.saturating_accrue(w);
debug_assert!(self.consumed.all_lte(self.limit), "Weight counter overflow");
}
/// Consume the given weight after checking that it can be consumed. Otherwise do nothing.
pub fn check_accrue(&mut self, w: Weight) -> bool {
self.consumed.checked_add(&w).map_or(false, |test| {
if test.any_gt(self.limit) {
false
} else {
self.consumed = test;
true
}
})
}
/// Check if the given weight can be consumed.
pub fn can_accrue(&self, w: Weight) -> bool {
self.consumed.checked_add(&w).map_or(false, |t| t.all_lte(self.limit))
}Trait Implementations§
source§impl AddAssign<Weight> for Weight
impl AddAssign<Weight> for Weight
source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
+= operation. Read moresource§impl CheckedAdd for Weight
impl CheckedAdd for Weight
source§fn checked_add(&self, rhs: &Self) -> Option<Self>
fn checked_add(&self, rhs: &Self) -> Option<Self>
None is
returned.source§impl CheckedSub for Weight
impl CheckedSub for Weight
source§fn checked_sub(&self, rhs: &Self) -> Option<Self>
fn checked_sub(&self, rhs: &Self) -> Option<Self>
None is returned.source§impl Decode for Weight
impl Decode for Weight
source§impl<'de> Deserialize<'de> for Weight
impl<'de> Deserialize<'de> for Weight
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Encode for Weight
impl Encode for Weight
source§fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy
)
fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy
)
source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
source§fn using_encoded<R, F>(&self, f: F) -> Rwhere
F: FnOnce(&[u8]) -> R,
fn using_encoded<R, F>(&self, f: F) -> Rwhere
F: FnOnce(&[u8]) -> R,
source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl MaxEncodedLen for Weight
impl MaxEncodedLen for Weight
source§fn max_encoded_len() -> usize
fn max_encoded_len() -> usize
source§impl Mul<Weight> for Perquintill
impl Mul<Weight> for Perquintill
source§impl PartialEq<Weight> for Weight
impl PartialEq<Weight> for Weight
source§impl SubAssign<Weight> for Weight
impl SubAssign<Weight> for Weight
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
-= operation. Read moreimpl Copy for Weight
impl EncodeLike<Weight> for Weight
impl Eq for Weight
impl StructuralEq for Weight
impl StructuralPartialEq for Weight
Auto Trait Implementations§
impl RefUnwindSafe for Weight
impl Send for Weight
impl Sync for Weight
impl Unpin for Weight
impl UnwindSafe for Weight
Blanket Implementations§
source§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere
T: Decode,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
source§impl<T> LowerBounded for Twhere
T: Bounded,
impl<T> LowerBounded for Twhere
T: Bounded,
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T. Read moresource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.source§impl<T, S> UniqueSaturatedFrom<T> for Swhere
S: TryFrom<T> + Bounded,
impl<T, S> UniqueSaturatedFrom<T> for Swhere
S: TryFrom<T> + Bounded,
source§fn unique_saturated_from(t: T) -> S
fn unique_saturated_from(t: T) -> S
T into an equivalent instance of Self.source§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T.