#operator #increase #inc #dec #now #pop #decrease

yanked ooo

The more operators for Rust. Such us 'Increase' and 'Decrease'.

1 unstable release

0.0.2 Feb 9, 2024
0.0.1 Feb 9, 2024
0.0.0 Feb 9, 2024

#6 in #dec

MIT license

34KB
1K SLoC

hello! every body. I think operators of the Rust is too less. So, I am making a extension of operators crate for the Rust. Thought it was not used by the Rust. I provite some interfaces to allow more functions in the Rust. Are you have some new idea or some suggest? Tell me please. Now is 0.0.2 version, so I only belive four functions(Increase, Decrease, Pop, Move). Your cheer is my power that forward.


lib.rs:

the extensions for operators of the Rust. until now, this crate provide four operators, such as DEC(decrease,same as substruct 1), INC(increase,same as add 1). these operators are same as some assmbly instructions. so you are not worth worrying workpiece. for exsample:

use ooo::inc::*; //use the trait that increase.
use ooo::ina::*; //use the trait that increase assign.
let mut x: usize = 300usize; //assign "300usize" to x.
assert_eq!(x, 300usize); //no problem.
x.inc_assign(); //add one to x when use trait "IncAssign".
assert_eq!(x, 301usize); //if you do it,should has not worings.
assert_eq!(x.inc(), 302usize); //add one again.it will be "302usize" when use trait "Inc".
assert_eq!(x, 301usize); //but you can know the variable "x" was not affected.
//because "inc" method return a new increased value and not affect self, 
//"inc_assign" method affect self and do not return anything.
use ooo::dec::*; //use the trait that decrease.
use ooo::dea::*; //use the trait that decrease assign.
x.dec_assign(); //substruct one to x when use trait "DecrefAssign"
assert_eq!(x, 301usize); //no ploblem.
assert_eq!(x.dec(), 300usize); //Allow method "decrease" when use trait "Dec"
assert_eq!(x, 301usize); //But also do not affect self.

if you have some suggest, welcome to tell me.my email is "ora_in_py@hotmail.com".

No runtime deps