chore(errors): Implementing Try and FromResidual for UserValue

Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
Louis van Liefland
2025-01-11 12:38:36 +11:00
committed by quexeky
parent 5af5bc7be4
commit a03e935b59
2 changed files with 23 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
use std::fmt::Display;
use std::{fmt::Display, ops::{FromResidual, Try}};
use serde::Serialize;
@@ -30,3 +30,23 @@ impl<T: Serialize, D: Display> From<Result<T, D>> for UserValue<T, D> {
}
}
}
impl<T: Serialize, D: Display> Try for UserValue<T, D> {
type Output = T;
type Residual = D;
fn from_output(output: Self::Output) -> Self {
Self::Ok(output)
}
fn branch(self) -> std::ops::ControlFlow<Self::Residual, Self::Output> {
todo!()
}
}
impl<T: Serialize, D: Display> FromResidual for UserValue<T, D> {
fn from_residual(residual: <Self as std::ops::Try>::Residual) -> Self {
todo!()
}
}

View File

@@ -1,3 +1,5 @@
#![feature(try_trait_v2)]
mod database;
mod games;