1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! The heap scalar-number representations: an 8-byte payload behind the
//! `NumberI64` / `NumberU64` / `NumberF64` tags.
//!
//! These are three separate representations — one per tag, in [`int`] (`I64Repr`),
//! [`uint`] (`U64Repr`), and [`float`] (`F64Repr`) — not one type that re-inspects
//! the tag: the tag alone determines the kind, so each owns its own decode and
//! construction, storing and reading its payload as its *actual* type. They share
//! only the typed allocation helpers here, which operate on the raw (aligned)
//! allocation pointer; applying and stripping the tag is the caller's (`IValue`'s)
//! responsibility.
pub use F64Repr;
pub use I64Repr;
pub use U64Repr;
use Layout;
use NonNull;
use crate;
/// The heap layout for a scalar payload of type `T` (an `i64`/`u64`/`f64`): `T`'s
/// own size, but forced to at least 8-byte alignment so the low tag bits of the
/// pointer stay free regardless of `T`'s natural alignment.
/// Allocates a heap scalar holding `value`, returning the aligned allocation.
/// Reads the payload as a `T`. Safety: `ptr` must be a live scalar whose 8 bytes
/// are a valid `T` (each representation reads back the type it stored; the raw bits
/// may also be read as `u64`).
///
/// `pub(super)`, not `pub(crate)`: the scalar reps that use it are child modules (which see
/// it regardless), and the only other caller is `IValue::number_repr_key`, a test in the
/// parent `value` module. Its siblings `alloc`/`free`/`layout` are fully private.
pub unsafe
/// Frees a scalar allocation of a `T` payload.
/// Safety: `ptr` must be a live scalar allocation of `T`.
unsafe