8000 GitHub - jake-stewart/sign-rs · GitHub
[go: up one dir, main page]

Skip to content
jake-stewartPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sign

a sign enum. pass it to operations to run forwards or backwards.

examples

use sign::{Sign, Directional};

// pick a direction and run the same code either way
let dir = if forward { Sign::Positive } else { Sign::Negative };

dir.add_assign(&mut i, 1);      // i += 1 or i -= 1
dir.max(a, b);                  // max(a, b) or min(a, b)
let (lo, hi) = dir.order(a, b); // (a, b) or (b, a)
// walk an iterator forward or backward
for ch in "hello".chars().direction(dir) {
    // ...
}
// index a slice in either direction
let s = "hello";
let sub = &s[dir.range(1..4)];

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages

0