Open sempervictus opened 10 months ago
Oh interesting, if this isn't in a deku derive macro you get a better error:
error[E0609]: no field `len` on type `Option<Len>`
--> examples/example.rs:16:7
|
16 | a.len;
| ^^^ unknown field
|
help: one of the expressions' fields has a field of the same name
|
16 | a.unwrap().len;
| +++++++++
When writing
the compiler can't figure out how to reference the
length
struct member fromsvc_dsc
because it's wrapped in anOption
.Since the macro notation doesn't allow use of
either due to
It doesn't like getting dereferenced or unwrapped due to the borrow checker either :smile:.
I finally did figure out that you can unwrap the reference to the
Option
by writing this asbut it was somewhat confounding there for a bit. Think it's worth looking at some sugar to handle options directly or at least documenting the access pattern for newcomers.