error[E0507]: cannot move out of `self.email` which is behind a shared reference
--> src/domain/user.rs:5:10
|
5 | #[derive(ormx::Table, Clone, Debug)]
| ^^^^^^^^^^^ move occurs because `self.email` has type `EmailAddress`, which does not implement the `Copy` trait
|
= note: this error originates in the derive macro `Table` (in Nightly builds, run with -Z macro-backtrace for more info)
So naturally, I reach out to the field option #[ormx(by_ref)] for email:
error[E0605]: non-primitive cast: `&EmailAddress` as `EmailAddress`
--> server/src/domain/user.rs:5:10
|
5 | #[derive(ormx::Table, Clone, Debug)]
| ^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
|
= note: this error originates in the derive macro `Table` (in Nightly builds, run with -Z macro-backtrace for more info)
tl;dr: The code generated when both by_ref and custom_type are used in conjunction doesn't add the & to the type in the cast, hence the error. This PR fixes that omission.
This PR aims to fix the combined usage of
#[ormx(by_ref, custom_type)]
:As an example, let's say I have a non-
Copy
customesqlx
type as part of my model, and I want to#[derive(ormx::Table)]
with theinsertable
option:In that case, I get the following error:
So naturally, I reach out to the field option
#[ormx(by_ref)]
foremail
:Now, the error becomes:
tl;dr: The code generated when both
by_ref
andcustom_type
are used in conjunction doesn't add the&
to the type in the cast, hence the error. This PR fixes that omission.