struct Id(u64);
then if `foo` is an `Id`, `foo.0` is the u64. struct Id(u64);
then if `foo` is an `Id`, `foo.0` is the u64. #[repr(transparent)]I often find myself thinking of Swift as a not-quite-fully-baked attempt at making a Rust, and this reinforces my impression.
I moreso meant in terms of the high-level features of Rust and how they integrate FP-style patterns into a C-style imperative language. Like tuple-based structs as discussed above, or control flow as expressions, like if and match.
The alternatives to the latter in Swift are
A) defining a dedicated function for the control flow, using return statements
B) defining but not initializing a let constant before the control flow statement
C) using the ternary operator, which is concise but doesn’t really allow for destructuring complex types
all of which are more verbose, less clear in intent, and IMO don’t embody’s Swift’s mantra of “clarity at the site of use” as well as Rust’s approach.
I could just use rawValue as the field name every time, but foo.rawValue is a lot less readable, IMO, than foo.0