summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-04-24 17:52:04 +0200
committerMatthias Beyer <mail@beyermatthias.de>2021-04-24 17:52:04 +0200
commit416d80b2f3b9a6c083f7e56cbba4d303140f2d5c (patch)
treee99a97daf6273ee1276c7f6835b755f8b6b88519
parentd24e9f037fdb86bd9f3618e1e95dfcf2e7741f12 (diff)
Change impl so that backend is passed from main()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--examples/config.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/examples/config.rs b/examples/config.rs
index a91aaee..453b2e2 100644
--- a/examples/config.rs
+++ b/examples/config.rs
@@ -8,22 +8,22 @@ pub struct Configuration {
}
impl BuildableCollection for Configuration {
- fn builder<B>(_backend: B) -> Box<dyn CollectionBuilder<Output = Self>>
- where B: Backend
+ fn builder<B>(backend: B) -> Box<dyn CollectionBuilder<Output = Self>>
+ where B: 'static + Backend
{
- Box::new(ConfigStructBuilder)
+ Box::new(ConfigStructBuilder(backend))
}
}
-pub struct ConfigStructBuilder;
-impl CollectionBuilder for ConfigStructBuilder {
+pub struct ConfigStructBuilder<B: 'static + Backend>(B);
+impl<B: 'static + Backend> CollectionBuilder for ConfigStructBuilder<B> {
type Output = Configuration;
fn build_collection(&self, value_desc: &str) -> Result<Self::Output> {
println!("Building {}", value_desc);
- let verbose = bool::builder(DialoguerBackend).build_value("Be verbose?")?;
- let values = Vec::<u8>::builder(DialoguerBackend).build_collection("List of values")?;
+ let verbose = bool::builder(self.0).build_value("Be verbose?")?;
+ let values = Vec::<u8>::builder(self.0).build_collection("List of values")?;
Ok(Configuration {
verbose,