From 70d9a394a9d4b969bdbdad4c509f4a3fcbc929ff Mon Sep 17 00:00:00 2001 From: Yohan Boogaert Date: Sat, 27 Feb 2021 17:35:07 +0100 Subject: [PATCH] Remove Boolinator (#88) * Remove use statement for boolinator * Replace boolinator as_some method by bool then method * Replace boolinator and_option method by bool then method --- Cargo.lock | 1 - yewprint/Cargo.toml | 3 --- yewprint/src/button_group.rs | 9 ++++----- yewprint/src/buttons.rs | 7 +++---- yewprint/src/card/mod.rs | 3 +-- yewprint/src/control_group.rs | 5 ++--- yewprint/src/divider.rs | 3 +-- yewprint/src/html_select.rs | 9 ++++----- yewprint/src/input_group.rs | 11 +++++------ yewprint/src/menu.rs | 14 +++++++------- yewprint/src/progressbar.rs | 5 ++--- yewprint/src/switch.rs | 7 +++---- yewprint/src/tabs.rs | 5 ++--- yewprint/src/tag.rs | 15 +++++++-------- yewprint/src/text.rs | 3 +-- yewprint/src/tree.rs | 3 +-- 16 files changed, 43 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6cc964e..8730a30 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -795,7 +795,6 @@ dependencies = [ name = "yewprint" version = "0.1.0" dependencies = [ - "boolinator", "heck", "id_tree", "regex", diff --git a/yewprint/Cargo.toml b/yewprint/Cargo.toml index c947d5e..19aeb65 100644 --- a/yewprint/Cargo.toml +++ b/yewprint/Cargo.toml @@ -20,9 +20,6 @@ yew = { git = "https://github.com/yewstack/yew.git", rev = "db3170f629f" } web-sys = "0.3" id_tree = { version = "1.7", optional = true } yewtil = { git = "https://github.com/yewstack/yew.git", rev = "db3170f629f", features = ["pure"] } -# NOTE: this dependency needs to be removed when the feature bool_to_option lands in stable -# https://github.com/rust-lang/rust/issues/64260 -boolinator = "2.4.0" [build-dependencies] regex = { version = "1", default-features = false, features = ["std", "unicode-perl"] } diff --git a/yewprint/src/button_group.rs b/yewprint/src/button_group.rs index da4022f..dbfad85 100644 --- a/yewprint/src/button_group.rs +++ b/yewprint/src/button_group.rs @@ -1,4 +1,3 @@ -use boolinator::Boolinator; use yew::prelude::*; pub struct ButtonGroup { @@ -47,10 +46,10 @@ impl Component for ButtonGroup {
diff --git a/yewprint/src/buttons.rs b/yewprint/src/buttons.rs index 450034d..b63dec6 100644 --- a/yewprint/src/buttons.rs +++ b/yewprint/src/buttons.rs @@ -1,5 +1,4 @@ use crate::{Icon, IconName, Intent}; -use boolinator::Boolinator; use yew::prelude::*; pub struct Button { @@ -54,9 +53,9 @@ impl Component for Button { @@ -86,12 +85,12 @@ impl Component for Tag { class=classes!( "bp3-tag", self.props.intent, - self.props.active.as_some("bp3-active"), - self.props.fill.as_some("bp3-fill"), - self.props.interactive.as_some("bp3-interactive"), - self.props.large.as_some("bp3-large"), - self.props.minimal.as_some("bp3-minimal"), - self.props.round.as_some("bp3-round"), + self.props.active.then(|| "bp3-active"), + self.props.fill.then(|| "bp3-fill"), + self.props.interactive.then(|| "bp3-interactive"), + self.props.large.then(|| "bp3-large"), + self.props.minimal.then(|| "bp3-minimal"), + self.props.round.then(|| "bp3-round"), self.props.class.clone(), ) onclick={self.props.onclick.clone()} diff --git a/yewprint/src/text.rs b/yewprint/src/text.rs index 060b3d1..163907d 100644 --- a/yewprint/src/text.rs +++ b/yewprint/src/text.rs @@ -1,4 +1,3 @@ -use boolinator::Boolinator; use yew::prelude::*; pub struct Text { @@ -46,7 +45,7 @@ impl Component for Text { <@{if self.props.inline { "span" } else { "div"}} class=classes!( self.props.class.clone(), - self.props.ellipsize.as_some("bp3-text-overflow-ellipsis"), + self.props.ellipsize.then (|| "bp3-text-overflow-ellipsis"), ) title?=self.props.title.clone() > diff --git a/yewprint/src/tree.rs b/yewprint/src/tree.rs index 626d9fc..71ea779 100644 --- a/yewprint/src/tree.rs +++ b/yewprint/src/tree.rs @@ -1,7 +1,6 @@ use crate::collapse::Collapse; use crate::icon::{Icon, IconName}; use crate::Intent; -use boolinator::Boolinator; use id_tree::*; use std::cell::{Ref, RefCell, RefMut}; use std::collections::hash_map::DefaultHasher; @@ -312,7 +311,7 @@ impl Component for TreeNode { html! {