[−][src]Crate batch_oper
batch_oper provides some batch operation macro for some operations
Features
default = ["std", "combin", "named-into", "macro-lit", "side-effect", "re-exports", "chain_panic", "chain_todo", "tuple_iter", "tuple_utils"]
"std"
Enable std"side-effect"
Enable mod side_effect"named-into"
Enable mod named_into"combin"
Enable mod combin"macro-lit"
Enable macro like new, list"chain_panic"
Enable mod chain_panic"chain_todo"
Enable mod chain_todo"tuples"
Enable mod tuples"once_get"
Enable mod once_get"re-exports"
Enable re-export of all mods
Usage
- Basic
- batch
||
equivalent tobop!(|| 4; == 2, > 3);
4 == 2 || 4 > 3;
- batch
&&
equivalent tobop!(&& 4; == 2, > 3);
4 == 2 && 4 > 3;
!
equivalent tobop!(|| a; == 1;!, == 2);
1 == a || a == 2
- batch op
equivalent to
bop!(&& 5; > ; 2, 3, 6;!);
5 > 2 && 5 > 3 && 6 > 5;
- batch
- Set
equivalent to
let mut a = 1; bop!(= a; + 1, - 2;!, * 3);
let mut a = 1; a = a + 1; a = 2 - a; a = a * 3;
- Let
equivalent to
bop! { let a|u8 = 1, mut b = 2 }
let a: u8 = 1; let mut b = 2;
- Let chain
- basic
equivalent to
let a = Some(1); let b = Some(2); let v: i32 = bop!(match && Some(va) = a, Some(vb) = b => { 1 } else { 2 });
let a = Some(1); let b = Some(2); let v: i32 = loop { if let Some(va) = a { if let Some(vb) = b { break { 1 }; } } break { 2 }; };
bool
equivalent tolet v: bool = bop!(bool match && Some(va) = a, Some(vb) = b => { 1 } else { 2 });
let v: bool = loop { if let Some(va) = a { if let Some(vb) = b { { 1 }; break true; } } { 2 }; break false; };
!loop
equivalent tolet v: i32 = bop!(!loop match && Some(va) = a, Some(vb) = b => { 1 } else { 2 });
let v: i32 = if let Some(va) = a { if let Some(vb) = b { { 1 } } else { { 2 } } } else { { 2 } };
!loop bool
equivalent tolet v: bool = bop!(!loop bool match && Some(va) = a, Some(vb) = b => { 1 } else { 2 });
let v: bool = if let Some(va) = a { if let Some(vb) = b { { 1 }; true } else { { 2 }; false } } else { { 2 }; false };
- basic
- In
equivalent to
let r = 0..5; let c = bop!(&1, &2 => in && r);
let r = 0..5; let c = r.contains(&1) && r.contains(&2);
||
equivalent tolet c = bop!(&1, &2 => in || r);
let c = r.contains(&1) || r.contains(&2);
- custom funcion name
ⓘThis example is not testedequivalent to
let c = bop!(has; &1, &2 => in && r);
ⓘThis example is not testedlet c = r.has(&1) && r.has(&2);
Using
equivalent tolet v = (1, 2); let v2 = (3, 4); using!((a, b) = v, (c, d) = v2; { println!("{} {} {} {}", a, b, c, d) })
let v = (1, 2); let v2 = (3, 4); { let (a, b) = v; let (c, d) = v2; { println!("{} {} {} {}", a, b, c, d) } }
Re-exports
pub use side_effect::*; |
pub use named_into::*; |
pub use combin::*; |
pub use chain_panic::*; |
pub use chain_todo::*; |
pub use crate::tuples::*; |
pub use crate::once_get::*; |
Modules
chain_panic | Chain Panic |
chain_todo | Chain Todo |
combin | No nesting combine |
named_into | Use chained calls to avoid nesting |
once_get | |
side_effect | Some extension functions that are convenient for side effects |
tuples | Re-exports from tuples |
Macros
arr | new a |
bop | batch opers |
btmap | new a |
btset | new a |
deque | new a |
heap | new a |
list | new a |
map | new a |
map_append | append items to a map |
new | new a |
set | new a |
using | using |