Skip to content

Rust Switch is a simple library that provides a very simple structure that is used to wrap the boolean data type, switching it's value after it has been used.

Notifications You must be signed in to change notification settings

RustUser/Rust-Switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Rust-Switch

Rust Switch is a simple library that provides a very simple structure that is used to wrap the boolean data type, switching it's value after it has been used.

I have provided a simple example as to where the structure can be used.

For example:

If you have a system where you need to take a boolean, and invert its value after it is used, this is the perfect implementation of this switch structure, as it does it for you.

New to rust, coming from Java? This is what it would look like in Java:

public Switch(boolean value) {
    this.value = value;
}

public boolean get() {
    return !this.invert();
}

public boolean invert() {
    return (this.value = !this.value);
}

public boolean view() {
    return this.value;
}

About

Rust Switch is a simple library that provides a very simple structure that is used to wrap the boolean data type, switching it's value after it has been used.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages