mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2025-09-24 23:41:30 +02:00
prowocessing: refactor trait based experiment to individual files
This commit is contained in:
parent
26996fbd00
commit
dddbcccf72
10 changed files with 362 additions and 341 deletions
48
crates/prowocessing/src/experimental/trait_based/data/raw.rs
Normal file
48
crates/prowocessing/src/experimental/trait_based/data/raw.rs
Normal file
|
@ -0,0 +1,48 @@
|
|||
#[derive(Clone, Copy)]
|
||||
pub enum Data<'a> {
|
||||
String(&'a str),
|
||||
Int(i32),
|
||||
}
|
||||
|
||||
impl Data<'_> {
|
||||
pub fn to_owned_data(&self) -> OwnedData {
|
||||
match self {
|
||||
Data::String(s) => (*s).to_owned().into(),
|
||||
Data::Int(i) => (*i).into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<'a> From<&'a str> for Data<'a> {
|
||||
fn from(value: &'a str) -> Self {
|
||||
Self::String(value)
|
||||
}
|
||||
}
|
||||
impl From<i32> for Data<'_> {
|
||||
fn from(value: i32) -> Self {
|
||||
Self::Int(value)
|
||||
}
|
||||
}
|
||||
impl<'a> From<&'a OwnedData> for Data<'a> {
|
||||
fn from(value: &'a OwnedData) -> Self {
|
||||
match value {
|
||||
OwnedData::String(s) => Data::String(s),
|
||||
OwnedData::Int(i) => Data::Int(*i),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum OwnedData {
|
||||
String(String),
|
||||
Int(i32),
|
||||
}
|
||||
impl From<String> for OwnedData {
|
||||
fn from(value: String) -> Self {
|
||||
Self::String(value)
|
||||
}
|
||||
}
|
||||
impl From<i32> for OwnedData {
|
||||
fn from(value: i32) -> Self {
|
||||
Self::Int(value)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue