Skip to content

A very (not) safe Rust library to check if a number is odd. Based on cve-rs.

License

Notifications You must be signed in to change notification settings

xnotime/odd_is_odd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A very (not) safe library to check if a number is odd. Abuses the same bugs and tricks in cve-rs to transmute the given i8 to a bool without using unsafe.

This relies on a compiler bug, almost certainly doesn't work on all platforms, and is possibly the least reasonable is_odd function you could imagine.

See https://www.youtube.com/watch?v=vfMpIsJwpjU&list=PLzl2iy0KCGD6N93omgPEjgakVYA5t-1oV

Example:

use odd_is_odd::is_odd;
fn main() {
    if (is_odd(69)) {
        println!("on our way to hundreds of thousands of downloads a week!");
    } else {
        println!("who could have guessed, the sketchy library is sketchy");
        assert!(false);
    }
}

About

A very (not) safe Rust library to check if a number is odd. Based on cve-rs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages