binarybit is both an executable binary that can be run, and a library that can be used in Rust programs.
Installing the command-line executable
Assuming you have Rust/Cargo installed , run this command in a terminal:
cargo install binarybit
It will make the binarybit command available in your PATH if you've allowed the PATH to be modified when installing Rust . cargo uninstall binarybit uninstalls.
Adding binarybit library as a dependency
Run this command in a terminal, in your project's directory:
cargo add binarybit
To add it manually, edit your project's Cargo.toml file and add to the [dependencies] section:
binarybit = "0.1.2"
The binarybit library will be automatically available globally.
Read the binarybit library documentation .
Back to the crate overview .
Readme
Projeto Rust - Enum Uwu
Este é um projeto Rust que apresenta um enum chamado Uwu , com variantes que podem ser consideradas como "verdadeiras" ou "falsas". O projeto também define métodos para inverter o valor lógico do enum (not ( ) ) e converte o enum em um valor booleano para ser usado diretamente em estruturas condicionais (if ).
Funcionalidade
O enum Uwu tem variantes que podem ser usadas como valores booleanos.
As variantes true são Yea , Yeah , Huzzah , Bliss , Kawaii e Yep e todas as outras são false . Portanto, o binarybit, apenas aceita: Nah , Nope , Nop , Meh e Owo como false .
O método not ( ) inverte o valor lógico atribuido para o objeto do tipo Uwu.
3. Exemplos de Uso
Declaração e Comparação
extern crate binarybit:: uwu:: Uwu;
use crate :: uwu:: Uwu;
fn main ( ) {
// Exemplos de declaração
let result_true: Uwu = Uwu:: yea( ) ;
let result_false: Uwu = Uwu:: nah( ) ;
// Você pode usar para especificar o valor de uma variável do tipo bool.
let some_bool: bool = Uwu:: huzzah( ) . into ( ) ;
println! ( " huzzah return --> {} " , some_bool) ;
println! ( " {:?} {:?} " , result_true, result_false) ;
// Método not e sintaxe no if
if result_true. into ( ) {
println! ( " Print this if true." ) ; // Isso será impresso
}
if Uwu:: not( result_false) . into ( ) {
println! ( " print this if not(false) == true." ) ;
}
}