summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers+gitlab@digital-scurf.org>2021-12-11 06:45:34 +0000
committerDaniel Silverstone <dsilvers+gitlab@digital-scurf.org>2021-12-11 06:45:34 +0000
commite8082fef03bd04042dad3fb2d0513587c54874ab (patch)
tree2115ecd5b0c121356693cbaefed13509e2e19dc3
parent826a78924bbed1bfd0e17a869a11ccf3d320bb9b (diff)
parenta5858f2dc142411d7acc5b4a9f84b786a5082eb5 (diff)
downloadsubplot-e8082fef03bd04042dad3fb2d0513587c54874ab.tar.gz
Merge branch 'tidyup' into 'main'
tidy ups See merge request subplot/subplot!241
-rwxr-xr-xcheck6
-rw-r--r--src/bindings.rs8
-rw-r--r--src/metadata.rs2
-rw-r--r--subplotlib/helpers/subplotlib_context.rs11
-rw-r--r--subplotlib/src/steplibrary/datadir.rs7
5 files changed, 9 insertions, 25 deletions
diff --git a/check b/check
index ac19c5f..cb5ffc1 100755
--- a/check
+++ b/check
@@ -107,7 +107,11 @@ class Runcmd:
def got_cargo(self, subcommand):
"""Is a cargo subcommand available?"""
p = self.runcmd(["cargo", "--list"], check=True, stdout=PIPE)
- lines = [line.strip() for line in p.stdout.decode("UTF-8").splitlines()]
+ lines = [
+ line.split()[0]
+ for line in p.stdout.decode("UTF-8").splitlines()
+ if line.strip()
+ ]
return subcommand in lines
def codegen(self, md, output, **kwargs):
diff --git a/src/bindings.rs b/src/bindings.rs
index 91a2c8d..2d5f062 100644
--- a/src/bindings.rs
+++ b/src/bindings.rs
@@ -393,17 +393,11 @@ mod test_binding {
}
/// Set of all known bindings.
-#[derive(Debug)]
+#[derive(Debug, Default)]
pub struct Bindings {
bindings: Vec<Binding>,
}
-impl Default for Bindings {
- fn default() -> Self {
- Bindings { bindings: vec![] }
- }
-}
-
#[derive(Debug, Deserialize)]
struct ParsedImpl {
function: String,
diff --git a/src/metadata.rs b/src/metadata.rs
index 0d0e844..3bc7268 100644
--- a/src/metadata.rs
+++ b/src/metadata.rs
@@ -77,7 +77,7 @@ impl Metadata {
let mut bindings = Bindings::new();
- get_bindings(&bindings_filenames, &mut bindings, template.as_deref())?;
+ get_bindings(&bindings_filenames, &mut bindings, template)?;
event!(Level::TRACE, "Loaded all metadata successfully");
diff --git a/subplotlib/helpers/subplotlib_context.rs b/subplotlib/helpers/subplotlib_context.rs
index b986ed2..c662c98 100644
--- a/subplotlib/helpers/subplotlib_context.rs
+++ b/subplotlib/helpers/subplotlib_context.rs
@@ -1,21 +1,12 @@
use std::collections::HashMap;
+#[derive(Default)]
struct Context {
counter: usize,
files: HashMap<String, SubplotDataFile>,
this_file: Option<SubplotDataFile>,
}
-impl Default for Context {
- fn default() -> Self {
- Self {
- counter: 0,
- files: HashMap::new(),
- this_file: None,
- }
- }
-}
-
impl Context {
fn remember_file(&mut self, name: &str, content: SubplotDataFile) {
self.files.insert(name.to_string(), content);
diff --git a/subplotlib/src/steplibrary/datadir.rs b/subplotlib/src/steplibrary/datadir.rs
index ab80d25..8aa6f00 100644
--- a/subplotlib/src/steplibrary/datadir.rs
+++ b/subplotlib/src/steplibrary/datadir.rs
@@ -10,6 +10,7 @@ use std::path::{Component, Path, PathBuf};
pub use crate::prelude::*;
+#[derive(Default)]
pub struct Datadir {
inner: Option<DatadirInner>,
}
@@ -18,12 +19,6 @@ pub struct DatadirInner {
base: tempfile::TempDir,
}
-impl Default for Datadir {
- fn default() -> Self {
- Self { inner: None }
- }
-}
-
impl ContextElement for Datadir {
fn created(&mut self, scenario: &Scenario) {
assert!(self.inner.is_none());