-
Notifications
You must be signed in to change notification settings - Fork 22
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
Useless lifetimes #19
Comments
Agreed, was trying to run the ipc client in a thread but couldnt share the Activity struct with the thread because of the lifetimes. ended up having to just make another struct that contains the data and sharing that instead. |
First thing to disclose: it's been a hot minute since I implemented the That aside, would it be preferable to make a breaking change wherein instead of chaining, it instead has let mut activity = Activity::new();
match activity_config.state {
Some(state) => {
debug!("Activity::State set to: {}", state);
activity.set_state(state);
}
None => debug!("Activity::State not found"),
}
match activity_config.details {
Some(details) => {
debug!("Activity::Details set to: {}", details);
activity.set_details(details);
}
None => debug!("Activity::Details not found"),
} Thanks for the thread :) |
Yes, why not. Activity::set_state(&mut self, new_state: &str) -> () {
self.state=new_state
} Could be very helpfull for thoses kind of scenarios. |
Alright, I'll plan to replace the current system with something like that in the next major version. |
I tried a bit more and it turns out that, in my case, using the kw match activity_config.state {
Some(ref state) => {
debug!("Activity::State set to: {}", state);
activity = activity.state(&state);
}
None => debug!("Activity::State not found"),
}
match activity_config.details {
Some(ref details) => {
debug!("Activity::Details set to: {}", details);
activity = activity.details(&details);
}
None => debug!("Activity::Details not found"),
} Even if that case worked; for other scenarios, having functions that take |
Hellow, im tring to have some sort of dynamic Activity,
But the fact that
activity::Activity
usesOption<&'a str>
instead ofOption<String>
+ that it's returningself
for each function makes that it's rly hard to use imo.I made a config-like structure to be used in .ron files so i can add or remove parts easily
(I know it's supposed to be chained but i can't find a way to make it work with the optional config that i am using)
Example:
This is impossible with the current type of
activity::Activity
The example above is working if you replace every
Option<&'a str>
byOption<String>
and remove lifetimes onactivity::Activity
It might just be me as im not very experienced with lifetimes, but i see no advantage of using
Option<&'a str>
instead ofOption<String>
.The text was updated successfully, but these errors were encountered: