CO3 is a Rust-focused FFI framework and language-extension that aims to make generic Rust code usable across the C ABI without forcing Rust to “fit” a foreign framework. It treats minimalism and idiomatic Rust as core aesthetics: developers write pure Rust and then declare imports/exports with a compact macro-based vocabulary. The model explicitly covers imports and exports of functions, statics, methods, and opaque types; the full Rust type space including sized and DSTs; representation and validity concerns (size, alignment, niches, trap values, pointee validation, custom invariants); value-passing semantics (borrowing, cloning, ownership transfer, and soft conversions); polymorphism via monomorphization and runtime-tag dispatch; and C-ABI adaptation such as symbol naming and compound-value unpacking.
CO3 prioritizes soundness by default, making any costs of safety explicit: values are lowered to checked C-compatible representations, ownership transfer is opt-in, and mutable-reference conversions can use temporary storage and writeback under an opt-in “soft” mode. A procedural-macro extension provides ergonomic support for static parameter monomorphization and checked runtime-tagged dispatch, plus symbol interpolation for matching real C naming conventions. Building CO3 required solving precursor problems packaged as disjoint_impls and rust-spec crates. The result is a unified, pragmatic model for bidirectional Rust↔C interfacing that balances zero-cost abstraction goals with defensible soundness guarantees.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.