rune/core/
object.rs

1//! The core object defintions.
2//!
3//! Objects are implemented as rust enum with at max a 56 bit payload. This
4//! means that it will always be 64 bits. 32 bit systems are not supported.
5//! Because of this it gives us more flexibility in the amount of information we
6//! can encode in the object header. For example, we can have 255 variants of
7//! objects before we need to box the object header. We are making the
8//! assumption that pointers are no bigger then 56 bits and that they are word
9//! aligned. All objects should be bound to a lifetime to ensure sound operation
10//! of the vm.
11
12mod buffer;
13mod cell;
14mod chartab;
15mod convert;
16mod float;
17mod func;
18mod hashtable;
19mod integer;
20mod string;
21mod symbol;
22mod tagged;
23mod vector;
24
25pub(crate) use buffer::*;
26pub(super) use cell::*;
27pub(crate) use chartab::*;
28pub(crate) use convert::*;
29pub(crate) use float::*;
30pub(crate) use func::*;
31pub(crate) use hashtable::*;
32pub(crate) use integer::*;
33pub(crate) use string::*;
34pub(crate) use symbol::*;
35pub(crate) use tagged::*;
36pub(crate) use vector::*;
37
38use std::fmt::Write as _;
39
40pub(crate) fn display_slice<T: std::fmt::Display>(slice: &[T]) -> String {
41    let mut buffer = String::new();
42    buffer.push('[');
43    for x in slice {
44        write!(&mut buffer, "{x} ").expect("failed to display slice");
45    }
46    buffer.push(']');
47    buffer
48}