MCPcopy Create free account
hub / github.com/PerroEngine/Perro / as_f64_lossy

Method as_f64_lossy

perro_source/core/perro_variant/src/variant.rs:104–119  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

102 | Number::U8(_)
103 | Number::U16(_)
104 | Number::U32(_)
105 | Number::U64(_)
106 | Number::U128(_)
107 )
108 }
109
110 #[inline]
111 pub const fn is_float(&self) -> bool {
112 matches!(self, Number::F32(_) | Number::F64(_))
113 }
114
115 #[inline]
116 pub fn as_i64_lossy(&self) -> Option<i64> {
117 match *self {
118 Number::I8(v) => Some(v as i64),
119 Number::I16(v) => Some(v as i64),
120 Number::I32(v) => Some(v as i64),
121 Number::I64(v) => Some(v),
122 Number::I128(v) => i64::try_from(v.get()).ok(),

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected