A timestamp in a log line often needs two operations. Extract the field, then interpret its date and offset. Hew 0.11.1 lets a regex match arm name the field and use it directly in its guard or body.
import std.time.datetime;
fn main() {
match "at 1970-01-01T01:29:59.999999999+01:30" {
re"^at (?P<date_text>.+)$" => {
let stamp = datetime.parse_iso8601(date_text).expect("timestamp");
println(datetime.to_iso8601(stamp).expect("UTC"));
}
_ => panic("missing timestamp"),
}
}This prints 1969-12-31T23:59:59.999999999Z. Here date_text is a string because every successful match contains the group. If a branch or a repetition can skip the group, Hew gives it type Option<string>. A group that matched an empty string contains .Some(""). Try the browser playground.
Share a record with C
Use #[repr(C)] on a compatible Hew record and #[export("symbol")] on a concrete function to expose it under a C symbol. A C caller can pass the record by value and receive one in return. Raw exports run deferred cleanup before terminating the process on an unrecovered fault. The checked host SDK supports callers that need to recover from a Hew fault. Hew exports · C caller
Upgrade an existing package
When another module calls an inherent method or associated constructor, mark it package fn for callers in the same package or pub fn for callers in other packages. An unmarked method belongs to its defining module.
hew run now gives interactive programs access to the terminal and returns the program’s exit status to the shell. On Windows this includes full-width native status codes.
For calendar code that stores timestamps, datetime.to_iso8601 and datetime.parse_iso8601 preserve nanoseconds and support numeric offsets. Check custom date formats when upgrading, especially fractional seconds and offsets. The complete release notes cover the format changes, native SDK linking and compiler improvements.