sync.Once's .Do and sync.OnceFunc both take func() — no return.
So the result has to live somewhere: a separate struct field you write to as a side effect.
sync.OnceValue takes func() T — the return value IS the cache. No extra field.
#golang#concurrency
time.After(d): Concurrency tool. Sets up a background timer and returns a channel.
t.After(u): Date/time method. Instant boolean comparison to check if timestamp t occurs after timestamp u.
#Golang time package
Go goroutine stack dumps show a bracketed state like [chan send] or [chan receive]: that means blocked. The full list lives in src/runtime/runtime2.go as waitReason constants. Not documented anywhere else. #golang
https://t.co/9aTetrDHIo
It’s great to see the #golang compiler using stack allocations to kill those noisy 1, 2, and 4-item heap allocations—even for escaping slices.
Optimized performance, automatically. https://t.co/6JmOjKBgG9
become allocation aware #ziglang
Check out the official list of Go replacements: https://t.co/BuA1CMpNSH
From Go 1.26+, `go fix` helps you with each of these replacements automatically! #golang
Catch compile time errors in your comptime assertion blocks in tests, skip runtime test execution: `zig test --test-no-exec <file.zig>` #ZigLang#Zig
-freference-trace[=num]: How many lines of reference trace should be shown per compile error—handy for getting more context without noisy output.
#ziglang often tells you “references hidden; use -freference-trace=…” in the error message. #zig
Rust 1.85.0 has been released! 🌈🦀✨
Not only does this release add async closures, it also includes a whole new Rust Edition, Rust 2024! 🎆🚀
Check out the blog post for an overview of all the changes and additions: https://t.co/kaVFfLAhRZ
An async function, when called, returns a Future because the Future is return type. This is just returning its return type like any regular function. The only change is Future wraps the declared return type in async function, to make the full return. #asyncrust
Rust Range Counting:
(low..=high).count() vs
(high-low) + 1
Both are equally fast - Range's count() uses optimized arithmetic under the hood. No iteration one by one in count. Calculates the number of steps between start and end using Step::steps_between!
#Rust#Rustlang
match some_string.as_str() {
"hello" => println!("Found hello"),
_ => println!("Something else")
}
Pattern Match:
https://t.co/vBSFmdmur2 shows String literals which are of &str type, not String. You can directly use "hello" but not "hello".to_string().
#rust#rustlang