Add setters to PollAnswer

This commit is contained in:
Temirkhan Myrzamadi 2020-07-28 16:19:52 +06:00
parent 3e34cf84c8
commit 52bba75e41

View file

@ -15,3 +15,34 @@ pub struct PollAnswer {
/// May be empty if the user retracted their vote.
pub option_ids: Vec<i32>,
}
impl PollAnswer {
pub fn new<S, O>(poll_id: S, user: User, option_ids: O) -> Self
where
S: Into<String>,
O: Into<Vec<i32>>,
{
Self { poll_id: poll_id.into(), user, option_ids: option_ids.into() }
}
pub fn poll_id<S>(mut self, val: S) -> Self
where
S: Into<String>,
{
self.poll_id = val.into();
self
}
pub fn user(mut self, val: User) -> Self {
self.user = val;
self
}
pub fn option_ids<S>(mut self, val: S) -> Self
where
S: Into<Vec<i32>>,
{
self.option_ids = val.into();
self
}
}