MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / to_u16

Method to_u16

ciphercore-base/src/data_values.rs:487–489  ·  view source on GitHub ↗

Converts `self` to a scalar if it is a byte vector, then casts the result to `u16`. # Arguments `st` - scalar type used to interpret `self` # Result Resulting scalar cast to `u16` # Examples ``` # use ciphercore_base::data_values::Value; # use ciphercore_base::data_types::INT32; let v = Value::from_scalar(-123456, INT32).unwrap(); assert_eq!(v.to_u16(INT32).unwrap(), -123456i32 as u16); ```

(&self, st: ScalarType)

Source from the content-addressed store, hash-verified

485 /// assert_eq!(v.to_u16(INT32).unwrap(), -123456i32 as u16);
486 /// ```
487 pub fn to_u16(&self, st: ScalarType) -> Result<u16> {
488 Ok(self.to_u128(st)? as u16)
489 }
490
491 /// Converts `self` to a scalar if it is a byte vector, then casts the result to `i16`.
492 ///

Callers

nothing calls this directly

Calls 1

to_u128Method · 0.45

Tested by

no test coverage detected