|
rstd 0.1.0
|
A C++ 20 module of Rust-like std.
C++’s language features are exciting, but I’m tired of the std.
Made this for coding with C++ easier.
I believe a standalone static-library std can solve many C++ pain points.
It doesn't have to mirror another language's stdlib — it could be designed to fit C++ idioms better.
My time is limited, so I anchored the design on Rust's std.
C++ has no linear type support, so types like NotNull and Unique cannot be fully enforced.
This project keeps them as part of the API and provides memcpy-like checks for null state.
No good design for a general Choice interface yet. Option/Result are implemented independently for now and may migrate once a Choice API is designed.
Could perhaps be done with some C++20 reflection magic, but I plan to wait for C++26.
| Module | Area | Types & APIs |
|---|---|---|
| core | types | Option<T>, Result<T,E> |
| traits | Impl / dyn dispatch, Clone, Copy, From / Into / AsRef / AsMut, PartialEq (partial) | |
| fmt | Display, Debug, Formatter, format_string, Arguments | |
| ptr | NonNull<T>(just api, no linear type support), ref<T>, mut_ref<T>, dyn<Trait> | |
| mem | ManuallyDrop, MaybeUninit | |
| str | str, CStr | |
| num | NonZero, integer traits | |
| sync | Atomic<T>, memory ordering | |
| ops | FnOnce, FnMut, Fn | |
| misc | Hash / Hasher, Duration, panic / PanicInfo, slice (partial) | |
| alloc | containers | Box<T>, Vec<T>, String, CString |
| shared ownership | Rc<T> / Weak<T>, Arc<T> / Weak<T> | |
| allocator | Layout, Global, alloc / dealloc | |
| std | io | Read, Write, Seek, BufRead traits, BufReader / BufWriter, Cursor<T>, Stdin / Stdout / Stderr, io::Error, print / println / eprint / eprintln |
| thread | spawn, sleep, park, yield_now, JoinHandle<T>, Builder, ThreadId | |
| sync | Mutex<T> / MutexGuard, mpsc::channel / sync_channel | |
| process | Command, Child, ExitStatus, Stdio, Output, ChildStdin / ChildStdout / ChildStderr (impl Read/Write), abort, exit, id | |
| env | var, set_var, remove_var | |
| time | Instant, SystemTime, Duration | |
| runtime | defaults | default allocator (operator new), panic handler (rstd_panic_impl) |
work in progress
Type Systems for Memory Safety
Borrowing Trouble: The Difficulties Of A C++ Borrow-Checker
rust-to-cpp-implementing-the-question-mark-operator rusty-cpp: Bringing Rust's safety to C++
fragile: A polyglot compiler that supports Rust, C++, Go
cxx: Safe interop between Rust and C++