Skip to content

feat: Add typed reference API#4

Open
samuelburnham wants to merge 8 commits intomainfrom
reference-api
Open

feat: Add typed reference API#4
samuelburnham wants to merge 8 commits intomainfrom
reference-api

Conversation

@samuelburnham
Copy link
Member

@samuelburnham samuelburnham commented Mar 20, 2026

  • Renames the owned reference type LeanObject to LeanOwned, and automates ref counting in Rust behind the Clone (lean_inc) and Drop (lean_dec) implementations. This mimics Lean's behavior and abstracts the unsafe inc/dec calls so the user usually doesn't have to worry about ref counting in Rust.
  • Adds a borrowed reference type LeanBorrowed<'_>, which doesn't require any ref counting as the caller guarantees the object outlives the borrowed reference. The lifetime parameter in Rust prevents the LeanBorrowed reference from being used after the source it was borrowed from is dropped or goes out of scope.
  • Adds a multi-threaded reference type LeanShared which is a wrapper around LeanOwned that marks the object as multi-threaded for atomic ref counting and safe Send and Sync implementations in Rust.
  • Moves the test/ sub-project to the top-level for simplicity, gating the Rust test code behind the test-ffi feature flag so it can live in the same crate
  • Simplifies CI by combining the CI and Valgrind tests, which were being run sequentially anyway. Note: this means the branch protection rule needs to be updated before merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant