Expand description
Rust bindings to Lean 4’s C API
Functions and comments manually translated from those in the lean.h header provided with Lean 4
Re-exports§
- pub use array::*;
- pub use closure::*;
- pub use constructor::*;
- pub use dbg::*;
- pub use external::*;
- pub use init::*;
- pub use int::*;
- pub use io::*;
- pub use libuv::*;
- pub use nat::*;
- pub use primitive::*;
- pub use sarray::*;
- pub use share_common::*;
- pub use string::*;
- pub use task::*;
- pub use thread::*;
- pub use thunk::*;
Modules§
- alloc
- array
- closure
- Closures
- constructor
- Constructor objects
- dbg
- Debugging helper functions
- external
- External objects
- init
- Utilities for initializing Lean’s runtime
- int
- Integers
- io
- IO Helper functions
- libuv
- nat
- Natural numbers
- panic
- primitive
- Primitive operations
- sarray
- Array of scalars
- share_common 
- string
- Strings
- task
- Tasks
- thread
- Utilities for initializing Lean threads
- thunk
- Thunks
Structs§
- IncompleteArray Field 
- lean_array_ object 
- Array arrays
- lean_closure_ object 
- lean_ctor_ object 
- lean_external_ class 
- lean_external_ object 
- lean_object 
- Lean object header.
- lean_promise_ object 
- lean_ref_ object 
- lean_sarray_ object 
- Scalar arrays
- lean_string_ object 
- lean_task_ imp 
- Data required for executing a Lean task. It is released as soon as the task terminates even if the task object itself is still referenced.
- lean_task_ object 
- Object of type Task _. The lifetime of alean_taskobject can be represented as a state machine with atomic state transitions.
- lean_thunk_ object 
Constants§
- LEAN_CLOSURE_ MAX_ ARGS 
- LEAN_MAX_ CTOR_ FIELDS 
- LEAN_MAX_ CTOR_ SCALARS_ SIZE 
- LEAN_MAX_ SMALL_ OBJECT_ SIZE 
- LEAN_MIMALLOC 
- LEAN_OBJECT_ SIZE_ DELTA 
- LEAN_SMALL_ ALLOCATOR 
- LeanArray 
- LeanClosure 
- LeanExternal 
- LeanMPZ
- LeanMaxCtor Tag 
- LeanPromise 
- LeanRef
- LeanReserved 
- LeanScalar Array 
- LeanString 
- LeanStruct Array 
- LeanTask 
- LeanThunk 
Functions§
- c_int_ ⚠load 
- layout_compat 
- lean_align 
- lean_alloc_ ⚠ctor_ memory 
- lean_alloc_ ⚠object 
- lean_alloc_ ⚠small 
- lean_alloc_ ⚠small_ object 
- lean_box 
- Box a usizeinto alean_object
- lean_dec ⚠
- lean_dec_ ⚠ref 
- lean_dec_ ⚠ref_ cold 
- lean_free_ ⚠object 
- lean_free_ ⚠small 
- lean_free_ ⚠small_ object 
- lean_get_ ⚠rc_ mt_ addr 
- lean_get_ slot_ idx 
- lean_has_ ⚠rc 
- Whether an object is reference counted
- lean_inc ⚠
- lean_inc_ ⚠heartbeat 
- lean_inc_ ⚠n 
- lean_inc_ ⚠ref 
- lean_inc_ ⚠ref_ n 
- lean_internal_ ⚠panic 
- lean_internal_ ⚠panic_ out_ of_ memory 
- lean_internal_ ⚠panic_ rc_ overflow 
- lean_internal_ ⚠panic_ unreachable 
- lean_is_ ⚠array 
- lean_is_ big_ object_ tag 
- lean_is_ ⚠closure 
- lean_is_ ⚠ctor 
- lean_is_ ⚠exclusive 
- lean_is_ ⚠exclusive_ obj 
- lean_is_ ⚠external 
- lean_is_ ⚠mpz 
- lean_is_ ⚠mt 
- Whether an object is multi-threaded
- lean_is_ ⚠persistent 
- lean_is_ ⚠promise 
- lean_is_ ⚠ref 
- lean_is_ ⚠sarray 
- lean_is_ scalar 
- Whether this lean object is a scalar
- lean_is_ ⚠shared 
- lean_is_ ⚠st 
- Whether an object is single-threaded
- lean_is_ ⚠string 
- lean_is_ ⚠task 
- lean_is_ ⚠thunk 
- lean_mark_ ⚠mt 
- lean_mark_ ⚠persistent 
- lean_obj_ ⚠tag 
- lean_object_ ⚠byte_ size 
- The object size may be slightly bigger for constructor objects.
The runtime does not track the size of the scalar size area.
All constructor objects are “small”, and allocated into pages.
We retrieve their size by accessing the page header. The size of
small objects is a multiple of LEAN_OBJECT_SIZE_DELTA
- lean_object_ ⚠data_ byte_ size 
- Returns the size of the salient part of an object’s storage, i.e. the parts that contribute to the value representation; padding or unused capacity is excluded. Operations that read from an object’s storage must only access these parts, since the non-salient parts may not be initialized.
- lean_panic ⚠
- lean_panic_ ⚠fn 
- lean_ptr_ ⚠other 
- lean_ptr_ ⚠tag 
- lean_set_ ⚠exit_ on_ panic 
- lean_set_ ⚠non_ heap_ header 
- Remark: we don’t need a reference counter for objects that are not stored in the heap. Thus, we use the area to store the object size for small objects.
- lean_set_ ⚠non_ heap_ header_ for_ big 
- lean_set_non_heap_headerfor (potentially) big objects such as arrays and strings.
- lean_set_ ⚠panic_ messages 
- Enable/disable panic messages
- lean_set_ ⚠st_ header 
- lean_small_ ⚠mem_ size 
- lean_small_ ⚠object_ size 
- lean_to_ ⚠array 
- lean_to_ ⚠closure 
- lean_to_ ⚠ctor 
- lean_to_ ⚠external 
- lean_to_ ⚠promise 
- lean_to_ ⚠ref 
- lean_to_ ⚠sarray 
- lean_to_ ⚠string 
- lean_to_ ⚠task 
- lean_to_ ⚠thunk 
- lean_unbox 
- Unbox a lean_objectinto ausize
- relaxed_rc_ ⚠load 
- Perform a relaxed load of the reference counter of o, which must be a pointer into a validlean_object
Type Aliases§
- b_lean_ obj_ arg 
- Borrowed object argument
- b_lean_ obj_ res 
- Borrowed object result
- lean_external_ finalize_ proc 
- lean_external_ foreach_ proc 
- lean_obj_ arg 
- Standard object argument
- lean_obj_ res 
- Standard object result
- u_lean_ obj_ arg 
- Unique (aka non shared) object argument