-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing lifetime
when doing from_ref
#16
Comments
Hi, thank you for reporting this! Will be looking into it, hopefully sooner than later. |
Hey @Artem-Romanenia, I think we have to discuss about the syntax here. The syntax I still can not wrap my head around how to distinguish between |
Hi @vnghia, I'm not quite sure what you mean by this
I suspect you are dealing with the following scenario struct Entity<T> {
field: T,
}
#[derive(o2o::o2o)]
#[map(Entity::<i16>)]
struct EntityDto {
field: i16,
} In this case, I think o2o doesn't care how it is spelled, it can be written as struct Entity<T> {
field: T,
}
#[derive(o2o::o2o)]
#[map(Entity<i16>)] // <- No turbofish here
struct EntityDto {
field: i16,
} and they will both expand in the same code. Honestly, I'm quite confused by rusts's turbofish in the first place 😄, but they just both happen to work.
So, previously, I used to think that mapping regular struct struct Entity<T> {
field: T,
}
struct EntityDto {
field: i16,
}
fn test<T>(t: Entity<T>) -> i16 {
// Do something with t
42
}
impl<T> From<Entity<T>> for EntityDto {
fn from(value: Entity<T>) -> Self {
EntityDto {
field: test(value)
}
}
} Now I think it makes some sense, but it is still hard to imagine some poor soul ever wanting to do this. So, I guess, for now let o2o bother only with mapping between regular If anybody ever needs to map #[derive(o2o::o2o)]
#[from_owned(Entity<T>| generic_impl_params(T))]
struct EntityDto {
#[from(test(@))]
field: i16,
} |
Hi! New behavior regarding lifetimes is available in v.0.4.10. Thanks again for the issue and for the pr! |
Hi thank you for this wonderful crate. One thing I notice is this does not work well with type with lifetime. For example this code does not work.
The text was updated successfully, but these errors were encountered: