mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2025-09-24 23:41:30 +02:00
simplified by entirely removing DataRef
This commit is contained in:
parent
619b7acf94
commit
911339fc2a
6 changed files with 19 additions and 69 deletions
|
@ -1,6 +1,6 @@
|
|||
//! Dynamic data storage and transfer types for use in [`io`]
|
||||
|
||||
/// Owned data type, for use mostly in outputs and storage
|
||||
// Dynamic data type
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Data {
|
||||
String(String),
|
||||
|
@ -18,41 +18,3 @@ impl From<i32> for Data {
|
|||
Self::Int(value)
|
||||
}
|
||||
}
|
||||
|
||||
/// Unowned data type, for inputs into runner functions
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum DataRef<'a> {
|
||||
String(&'a str),
|
||||
Int(i32),
|
||||
}
|
||||
|
||||
impl DataRef<'_> {
|
||||
/// converts itself to `OwnedData`
|
||||
pub fn to_owned_data(&self) -> Data {
|
||||
match self {
|
||||
DataRef::String(s) => (*s).to_owned().into(),
|
||||
DataRef::Int(i) => (*i).into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a str> for DataRef<'a> {
|
||||
fn from(value: &'a str) -> Self {
|
||||
Self::String(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i32> for DataRef<'_> {
|
||||
fn from(value: i32) -> Self {
|
||||
Self::Int(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a Data> for DataRef<'a> {
|
||||
fn from(value: &'a Data) -> Self {
|
||||
match value {
|
||||
Data::String(s) => DataRef::String(s),
|
||||
Data::Int(i) => DataRef::Int(*i),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue