Skip to content

Commit

Permalink
add new idea of Base trait
Browse files Browse the repository at this point in the history
Signed-off-by: Kosuke Morimoto <[email protected]>
  • Loading branch information
kmrmt committed Mar 7, 2024
1 parent dbf693f commit 42175a2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions rust/libs/algorithm/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,27 @@ pub mod algorithm {
fn new(p: Option<P>) -> Result<Self>;
}
}

pub mod algorithm2 {
use anyhow::Result;

pub trait Search<T, P, R> {
fn search(&self, v: &[T], p: Option<P>) -> Result<R>;
}

pub trait Insert<T, U, P, R> {
fn insert(&self, v: &[T], id: &U, p: Option<P>) -> Result<R>;
}

pub trait Update<T, U, P, R> {
fn update(&self, v: &[T], id: &U, p: Option<P>) -> Result<R>;
}

pub trait Remove<U, P, R> {
fn remove(&self, id: &U, p: Option<P>) -> Result<R>;
}

pub trait Commit<P, R> {
fn commit(&self, p: Option<P>) -> Result<R>;
}
}

0 comments on commit 42175a2

Please sign in to comment.