Repository navigation
Closes sub-phase 5B: Core Language Completion, built across v5.6.0 to v5.37.3.
Before 5B, closures over non-Copy values, borrowed iteration, generics nested in generics and half-precision arithmetic were rejected although the language reference describes them. They now compile and run, so code written the way the reference shows it works. This release also fixes a memory fault found in the closing audit: a chained read, store or method call through a borrow held in a struct field addressed the slot holding the borrow instead of the borrowed value.
What landed:
StringBuilder. The growable text type is renamed fromString, sostringandStringBuilderare no longer one letter apart.- Reading through a borrow. Built-in operators take borrowed operands, and method receivers dereference automatically.
- Half precision.
f16andbf16have scalar arithmetic, comparisons, math methods and.to_checked, each operation correctly rounded. - Generics.
Selfas a type, an enclosing type parameter insideOption<T>orWrapper<T>, generic methods with the method turbofish, generic trait methods, supertraits, and operator traits on every type. - Declarable
Copy,Clone,Debug,PartialEqandHashable, withT: CopyandT: Clonebounds a generic body can use, including through references. - Closures. Capture by
&,&mutandmove, capture by value inferred from a move out of the capture, theFn,FnMutandFnOncecall modes, inference, and closures that escape with their own environment. Borrowing closures can be stored in structs, tuples and arrays, and returned by combinators such ascompose(f, g). - Function values. Instantiated generics and associated functions work as values, and any function value is a
|>target or a>>operand. OptionandResultmethods..map,.map_err,.ok,.ok_or, theis_*family, and a diverging??fallback.- References in structs and enums. Fields and payloads hold borrows,
Option<&T>included, and the checker tracks what each holder borrows. - Collections of owners.
Vec,HashMapandBTreeMapown non-Copyelements: insertion moves, indexing names a place, lookup borrows. - Iteration.
for x in &vyields&Tand&mut vyields&mut T. Iterator adapters (.map,.filter,.enumerate) and ranges (0..n,.rev(),.step(n)) are values that bind, pass and return, and maps iterate in all three receiver modes. - Surface additions. Loop labels written
'outer:,@on the multiplicative row, bitwise compound assignment, tuple element places,if valandwhile val, binding alternatives, nested payload patterns,@bindings and array patterns inmatch, and.parse::<T>()on strings. - Ownership fixes found on the way. Pool-aware values release once per loop iteration, a
&mutmoves instead of copying, abreakvalue carries its borrows, and a temporary struct releases the strings its construction allocated.
Known gaps are in docs/BUGS.md:
- BUG-085, BUG-082 and BUG-077: a
stringbuffer leaks when a struct is passed by value, when an enum owns it, or when a store through a borrow displaces it. The program stays correct and grows. - BUG-152: a method whose signature nests its own type in itself is refused at 128 levels.
- BUG-138: a private function in an imported module is reachable by its bare name.
- BUG-155: a panic inside the standard library or an imported module reports a position in the program's file.
- BUG-027: a const generic parameter cannot be passed on to another generic call.
Next: sub-phase 5C, Standard Library & First Training Run (a prebuilt Linux neurc, hierarchical module namespaces, a standard library written in Neuro, @test, file and .safetensors I/O).
Per-version detail is in CHANGELOG.md.