Crate powerletters
Power Letters for Rust
Concise spellings of common Rust operations:
C-CloneO-ToOwnedS-ToStringI- IgnoreResultX-expectforResultandOption
All operations are provided as both functions and methods. Sometimes one reads better than the other.
In action:
# use *;
# use Path;
# ;
#
# let path = new;
# let pathgen = PathGen;
let mut parents: = path.ancestors.skip.map.collect;
Power Clone
use *;
let bagostuff = vec!;
let newbag = bagostuff.C;
// or
let newbag = C;
Power ToOwned
use *;
use Path;
let yourpath = new;
let mypath = yourpath.O;
// or
let mypath = O;
Power ToString
use *;
let s: String = S;
// or
let s: String = "foo".S;
Power ignore Result - kick that Result to the curb!
use *;
use Write;
let mut buf = Vecnew;
write!.I;
// or
I;
Note this is superior to let _ = ...
because the let version is untyped and can
introduce unintended bugs like ignoring futures.
Power expect for Result and Option.
use *;
# use io;
let maybe_thing = Some;
let thing = maybe_thing.X; // like `.expect("some baloney")`
let good_thing: = Ok;
let thing = good_thing.X;
// or
let maybe_thing = Some;
let thing = X;
let good_thing: = Ok;
let thing = X;
Panics with helpful messages:
# use powerletters::*;
let none: Option<i32> = None;
let value = none.X();
// thread 'main' panicked at src/main.rs:3:19:
// impossible `None` option
# use powerletters::*;
let err: Result<i32, _> = Err("something went wrong");
let value = err.X();
// thread 'main' panicked at src/main.rs:3:18:
// impossible `Err` result: something went wrong
Traits
-
PowerClone
Power
Clone. -
PowerExpect
Power
expectforResultandOption. -
PowerToOwned
Power
ToOwned. -
PowerToString
Power
ToString. -
ResultIgnore
Power ignore
Result- kick thatResultto the curb!