This commit is contained in:
parent
291949b8c6
commit
a89c566120
2 changed files with 30 additions and 17 deletions
|
@ -222,7 +222,20 @@ impl<'r> FromRequest<'r> for MaybeUser {
|
|||
|
||||
impl From<MaybeUser> for Option<User> {
|
||||
fn from(value: MaybeUser) -> Self {
|
||||
match value {
|
||||
value.take_user()
|
||||
}
|
||||
}
|
||||
|
||||
impl MaybeUser {
|
||||
pub fn user(&self) -> Option<&User> {
|
||||
match self {
|
||||
MaybeUser::User(user) => Some(user),
|
||||
MaybeUser::Anonymous => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn take_user(self) -> Option<User> {
|
||||
match self {
|
||||
MaybeUser::User(user) => Some(user),
|
||||
MaybeUser::Anonymous => None,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue