Skip to main content

Hew 0.11.2: module-private record fields and faster release builds

· 2 min read
v0.11.2

A record often pairs public fields with internal state that callers should not alter directly. Hew 0.11.2 lets you mark fields private on named records so reads, construction and updates of those fields stay inside the declaring module:

pub type Receipt {
    label: string;
    private sequence: i64;
}
 
impl Receipt {
    pub fn issue(label: string, sequence: i64) -> Receipt {
        Receipt { label: label, sequence: sequence }
    }
 
    pub fn sequence(self) -> i64 {
        self.sequence
    }
}
 
fn main() {
    let paid = Receipt.issue("invoice", 42);
    let updated = Receipt { label: "settled", ..paid };
    println(f"{updated.label} #{updated.sequence()}");
}

This prints settled #42. Other modules can read label, call sequence() and build a modified copy with Receipt { label: "settled", ..paid } while preserving the private sequence; direct field access or overrides of sequence from outside the declaring module are rejected. Editor completions, hover documentation and syntax highlighting respect the same boundary. Try the browser playground.

Migrate cache fields and CLI commands

std.cache.Cache fields are now module-private. Replace direct field reads and writes with capacity(), ttl() and set_limits(capacity, ttl). std.cache also adds touch(key) to refresh a live entry’s TTL, eviction: .Lru for least-recently-used eviction, faster expiry pruning that avoids scanning live entries and cache: prefixes on CacheError display messages.

Top-level hew compile and hew playground verify aliases have been removed:

  • Use hew build to produce an executable.
  • Replace hew compile with hew tool compile (same arguments; bare hew file.hew keeps its existing artifact paths).
  • Replace hew playground verify with hew tool playground-verify.

Faster builds, stdlib updates and security

Large static --release builds (or --opt-level 2 without -g) on Linux x86-64 (glibc) can parallelize native object emission when sufficient CPU and memory headroom, ld.lld and llvm-objcopy or objcopy are available, verifying linked source ranges before using the split object. Code generation, ownership checking and the runtime also trim coroutine frame storage, repeated aggregate checks and allocation overhead.

In the standard library and tooling, Arena.contains and Arena.remove no longer require T: Clone, std.stream resumes newline scans across chunked input, std.random runs weighted draws in Hew across both native and browser targets, YAML decoding preserves indentation in multiline strings, std.text.markdown / hew doc normalize empty heading ranges and editor tooling colours contextual failure syntax.

Dependency updates bump url to 2.5.9 to address RUSTSEC-2026-0592 and align regex on 1.13.2. See the complete release notes for the full list of changes and migration details.

Hew Notes

Language development, engineering articles, releases and community projects, about once a month, with an extra issue for a significant release. Written in English.

Subscribe to Hew Notes