-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix bug where we could not accept constants as sizes in array_refs!
- Loading branch information
Showing
4 changed files
with
34 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#[macro_use] | ||
extern crate arrayref; | ||
|
||
fn main() { | ||
let x = [0,1,2,3,4,5,6,7,8,9]; | ||
let (a,b,c) = array_refs!(&x, 2, 3, 5); | ||
assert_eq!(2, a.len()); | ||
assert_eq!(3, b.len()); | ||
assert_eq!(5, c.len()); | ||
assert_eq!(*a, [0,1]); | ||
assert_eq!(*b, [2,3,4]); | ||
assert_eq!(*c, [5,6,7,8,9]); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#[macro_use] | ||
extern crate arrayref; | ||
|
||
const SIZE: usize = 10; | ||
const SIZE_A: usize = 2; | ||
const SIZE_B: usize = 3; | ||
const SIZE_C: usize = 5; | ||
|
||
fn main() { | ||
let x: [u8; SIZE] = [0,1,2,3,4,5,6,7,8,9]; | ||
let (a,b,c) = array_refs!(&x, SIZE_A, SIZE_B, SIZE_C); | ||
assert_eq!(SIZE_A, a.len()); | ||
assert_eq!(SIZE_B, b.len()); | ||
assert_eq!(SIZE_C, c.len()); | ||
assert_eq!(*a, [0,1]); | ||
assert_eq!(*b, [2,3,4]); | ||
assert_eq!(*c, [5,6,7,8,9]); | ||
} |
This file contains 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