converting the parameters
This commit is contained in:
parent
876bced188
commit
9573480973
@ -29,8 +29,8 @@ pub struct OwnedPath {
|
|||||||
pub keys: Vec<String>,
|
pub keys: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<RValue<'_>> for OwnedRValue {
|
impl From<&RValue<'_>> for OwnedRValue {
|
||||||
fn from(original: RValue<'_>) -> Self {
|
fn from(original: &RValue<'_>) -> Self {
|
||||||
match original {
|
match original {
|
||||||
RValue::RVString(text) => OwnedRValue::RVString(text.to_owned()),
|
RValue::RVString(text) => OwnedRValue::RVString(text.to_owned()),
|
||||||
RValue::RVPath(path) => OwnedRValue::RVPath(OwnedPath {
|
RValue::RVPath(path) => OwnedRValue::RVPath(OwnedPath {
|
||||||
@ -42,6 +42,24 @@ impl From<RValue<'_>> for OwnedRValue {
|
|||||||
|
|
||||||
pub struct NewParametersContext {
|
pub struct NewParametersContext {
|
||||||
params: HashMap<String, OwnedRValue>,
|
params: HashMap<String, OwnedRValue>,
|
||||||
|
breadcrumbs: Vec<Box<dyn ContextElement>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NewParametersContext {
|
||||||
|
pub fn new(
|
||||||
|
breadcrumbs: &Vec<&dyn ContextElement>,
|
||||||
|
params: &Vec<KVPair>,
|
||||||
|
) -> NewParametersContext {
|
||||||
|
let owned_params: HashMap<String, OwnedRValue> = params
|
||||||
|
.iter()
|
||||||
|
.map(|kvpair| (kvpair.key.to_string(), OwnedRValue::from(&kvpair.value)))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
NewParametersContext {
|
||||||
|
params: owned_params,
|
||||||
|
breadcrumbs: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user