diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-10-22 11:59:50 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-10-22 11:59:50 +0000 |
commit | 1bcbb535490511e0bc4f2826356a16bdd05360b0 (patch) | |
tree | 1e26b5616d61e9fc917278012f75d707bbfd97fa /src/bindings.rs | |
parent | 990c506d347a6aa09af68bc6de670858cf59f133 (diff) | |
parent | 7f52ffc37e1a366f78ba3709f15b09ca22ca98c9 (diff) | |
download | subplot-1bcbb535490511e0bc4f2826356a16bdd05360b0.tar.gz |
Merge branch 'filepath-as-path' into 'main'
(derive): Support steps with &Path arguments
Closes #288
See merge request subplot/subplot!295
Diffstat (limited to 'src/bindings.rs')
-rw-r--r-- | src/bindings.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/bindings.rs b/src/bindings.rs index 8c33cc4..8e3531b 100644 --- a/src/bindings.rs +++ b/src/bindings.rs @@ -49,6 +49,10 @@ pub enum CaptureType { /// for one of the embedded files in the document, otherwise codegen will /// refuse to run. File, + + /// Paths are sequences of non-whitespace characters which will be interpreted + /// as a file-path (e.g. PathBuf) or similar when processed by a step + Path, } impl FromStr for CaptureType { @@ -62,6 +66,7 @@ impl FromStr for CaptureType { "uint" => Ok(Self::Uint), "number" => Ok(Self::Number), "file" => Ok(Self::File), + "path" => Ok(Self::Path), _ => Err(SubplotError::UnknownTypeInBinding(value.to_string())), } } @@ -77,6 +82,7 @@ impl CaptureType { Self::Uint => "uint", Self::Number => "number", Self::File => "file", + Self::Path => "path", } } @@ -89,6 +95,7 @@ impl CaptureType { Self::Uint => r"\d+", Self::Number => r"-?\d+(\.\d+)?", Self::File => r"\S+", + Self::Path => r"\S+", } } } @@ -787,6 +794,7 @@ lazy_static! { CaptureType::Uint, CaptureType::Number, CaptureType::File, + CaptureType::Path, ]).iter().copied() { // This Unwrap is okay because we shouldn't have any bugs in the // regular expressions here, and if we did, it'd be bad for everyone |