3 ms·
Rust's slog ( https://docs.rs/slog/ https://docs.rs/slog/ ) does: use slog::info; ... info!("hello, world"; "user" => std::env::var("USER"));
by richardwhiuk 3y ago
Rust's slog ( https://docs.rs/slog/ https://docs.rs/slog/ ) does:
use slog::info;
...
info!("hello, world"; "user" => std::env::var("USER"));
- codetrotter 3y agoYup! Love the Rust slog crate. Initially thought OP was gonna be about Rust slog, before I saw the domain mention Go.
- masklinn 3y agoIt can do that because Rust’s macros can have their own mini language at the top level, and can transform that into whatever data structure they want under the cover. For better or for worse, Go doesn’t have that.
- masklinn 3y agoAlso funny story: in Perl “,” can be spelled “=>” specifically for this sort of use cases, when you write my %hash = ( Foo => “bar”, Baz => “qux”, ); the behaviour is no different than my %hash = ( Foo, “bar”, Baz, “qux”, ); it’s just that a literal plist in a hash context is interpreted as a hash. Hence “=>” being called “fat comma” in perl. Which means you can writer my %h = (a => b => c => d); or my %h = (a, b => c, d); they all mean the same thing.
- richardwhiuk 3y agoThat all sounds questionable.