4 ms·
Yes, `&*foo` is meaningful. For example, `Vec<T>` becomes `[T]` and then `&[T]`. Yes, a `Box<dyn Error>` is about the most rudimentary way of returning an arbi
by shepmaster 2y ago
Yes, `&*foo` is meaningful. For example, `Vec<T>` becomes `[T]` and then `&[T]`.
Yes, a `Box<dyn Error>` is about the most rudimentary way of returning an arbitrary error, but it’s better than a panic or a sentinel value.
- nick__m 2y agoYour example is not what the dbus crate does, in your case everything is related to T, it doesn't surprise! In that crate the &*msg.interface().unwrap() magically become an &str !
- shepmaster 2y agoI don’t know the dbus crate, so I’m not trying to say anything about that crate’s usage, I’m simply saying that referencing after dereferencing is idiomatic Rust. For example, the standard library `String` type dereferences to `str` which you can then re-reference to `&str`.
- nick__m 2y agoSorry, I should have been clearer in my question, I wanted to know about A deref to B re-ref to &B. ameliaquining awnsered my question and you modulated my opinion, that pattern is can be idiomatic when the principle of minimal surprises is respected.