Created
February 16, 2014 19:11
-
-
Save pzol/9039158 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn pos(pos: int, len: uint) -> uint { | |
| let ilen = len as int; | |
| let result = match pos { | |
| p if p < 0 && ilen + p < 0 => 0, | |
| p if p < 0 => ilen + p, | |
| p => p | |
| } as uint; | |
| result | |
| } | |
| #[test] | |
| fn test_slice_pos(){ | |
| let p = pos(-1, 10); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment