sim_value/lib.rs
1//! Ergonomic construction and access for kernel `Expr` data.
2//!
3//! The kernel `Expr` enum is bare data with no ergonomic surface, so dozens of
4//! libs independently re-grew `sym`/`number`/`field`/`set`/`expr_kind` and a
5//! `k`/`i` path-addressing scheme. This crate is the one home for that. It
6//! depends only on `sim-kernel` and adds data ergonomics, not runtime behavior,
7//! so it does not touch the kernel boundary.
8//!
9//! - [`build`]: constructors (`sym`, `int`, `float`, `text`, `list`, `map`, ...);
10//! - [`access`]: reading and immutable updates (`field`, `set`, `remove`, ...);
11//! - [`kind`]: the one `Expr` variant classifier (`expr_kind`);
12//! - [`path`]: one value-addressing primitive (`Path`, `get`, `set_at`).
13//!
14//! # Example
15//!
16//! ```
17//! use sim_value::access::{field, set};
18//! use sim_value::build::{int, map, sym};
19//!
20//! let value = map(vec![("a", int(1)), ("b", int(2))]);
21//! assert_eq!(field(&value, "a"), Some(&int(1)));
22//!
23//! let updated = set(&value, "a", int(9));
24//! assert_eq!(field(&updated, "a"), Some(&int(9)));
25//! assert_eq!(field(&updated, "b"), Some(&int(2))); // siblings preserved
26//! let _ = sym("ok");
27//! ```
28
29#![forbid(unsafe_code)]
30#![deny(missing_docs)]
31
32pub mod access;
33pub mod build;
34pub mod kind;
35pub mod path;
36
37#[cfg(test)]
38mod tests;