Open Montel opened 3 months ago
error[E0308]: mismatched types --> crates/cxx-qt-lib/src/gui/qpen.rs:186:9 | 184 | fn as_ref(&self) -> &ffi::QPen { | ---------- expected &qpen::QPen because of return type
185 |
let pen = ffi::qpen_init_from_qcolor(&self); 186 | pen | ^^^ expected &QPen , found QPen |
---|
help: consider borrowing here | 186 | &pen | +
For more information about this error, try rustc --explain E0308
.
The following warnings were emitted during compilation:
but if I use &pen if doesn't compile too.
Do you have an idea ? thanks
warning: cxx-qt-lib@0.6.0: Compiler version doesn't include clang or GCC: "c++" "--version"
error[E0515]: cannot return reference to local variable pen
--> crates/cxx-qt-lib/src/gui/qpen.rs:186:9
|
186 | &pen
| ^^^^ returns a reference to data owned by the current function
For more information about this error, try rustc --explain E0515
.
The following warnings were emitted during compilation:
Fun :-) so because it wants a reference the lifetime is the fun part here. Either we would need to link up the lifetimes somehow (not sure if possible?) or maybe we'd need to go the Into
route instead as that could be a value not a reference, eg accept Into<QPen>
we also need to see what is the common way of doing this in the Rust ecosystem, so looking for examples in std would be good.
Also note that From<T>
is usually preferred over Into<T>
@LeonMatthesKDAB do you have an idea how to fix it ? :)
Closed: #810