oxilean_runtime/object/rtobject_small_int_group.rs
1//! # RtObject - small_int_group Methods
2//!
3//! This module contains method implementations for `RtObject`.
4//!
5//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
6
7use super::functions::{MAX_SMALL_INT, MIN_SMALL_INT, PAYLOAD_MASK, TAG_INT};
8use super::rtobject_type::RtObject;
9
10impl RtObject {
11 /// Create a small signed integer.
12 pub fn small_int(n: i64) -> Option<Self> {
13 if !(MIN_SMALL_INT..=MAX_SMALL_INT).contains(&n) {
14 return None;
15 }
16 let payload = if n >= 0 {
17 n as u64
18 } else {
19 (n as u64) & PAYLOAD_MASK
20 };
21 Some(RtObject {
22 bits: ((TAG_INT as u64) << 56) | payload,
23 })
24 }
25}