mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-11 03:04:22 +01:00
Add remap vec to parameters.rs to allow for reordering of arguments
This commit is contained in:
@@ -27,6 +27,7 @@ impl Parameter {
|
||||
pub struct Parameters {
|
||||
index: NonZero<usize>,
|
||||
pub list: Vec<Parameter>,
|
||||
remap: Vec<NonZero<usize>>,
|
||||
}
|
||||
|
||||
impl Default for Parameters {
|
||||
@@ -40,6 +41,7 @@ impl Parameters {
|
||||
Self {
|
||||
index: 1.try_into().unwrap(),
|
||||
list: vec![],
|
||||
remap: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +51,14 @@ impl Parameters {
|
||||
params.len()
|
||||
}
|
||||
|
||||
pub fn set_remap(&mut self, remap: Vec<NonZero<usize>>) {
|
||||
self.remap = remap;
|
||||
}
|
||||
|
||||
pub fn get_remap(&self, idx: NonZero<usize>) -> NonZero<usize> {
|
||||
*self.remap.get(idx.get() - 1).unwrap_or(&idx)
|
||||
}
|
||||
|
||||
pub fn name(&self, index: NonZero<usize>) -> Option<String> {
|
||||
self.list.iter().find_map(|p| match p {
|
||||
Parameter::Anonymous(i) if *i == index => Some("?".to_string()),
|
||||
|
||||
Reference in New Issue
Block a user