2014-04-02 03:39:26 +00:00
|
|
|
pub fn main() {
|
2016-10-29 21:54:04 +00:00
|
|
|
let v: Vec<isize> = vec![0, 1, 2, 3, 4, 5];
|
2014-05-25 10:17:19 +00:00
|
|
|
let s: String = "abcdef".to_string();
|
2015-02-18 10:42:01 +00:00
|
|
|
v[3_usize];
|
2015-02-02 02:53:25 +00:00
|
|
|
v[3];
|
2019-01-14 13:10:45 +00:00
|
|
|
v[3u8]; //~ERROR : the type `[isize]` cannot be indexed by `u8`
|
|
|
|
v[3i8]; //~ERROR : the type `[isize]` cannot be indexed by `i8`
|
|
|
|
v[3u32]; //~ERROR : the type `[isize]` cannot be indexed by `u32`
|
|
|
|
v[3i32]; //~ERROR : the type `[isize]` cannot be indexed by `i32`
|
2015-02-18 10:42:01 +00:00
|
|
|
s.as_bytes()[3_usize];
|
2015-01-04 04:43:24 +00:00
|
|
|
s.as_bytes()[3];
|
2019-01-14 13:10:45 +00:00
|
|
|
s.as_bytes()[3u8]; //~ERROR : the type `[u8]` cannot be indexed by `u8`
|
|
|
|
s.as_bytes()[3i8]; //~ERROR : the type `[u8]` cannot be indexed by `i8`
|
|
|
|
s.as_bytes()[3u32]; //~ERROR : the type `[u8]` cannot be indexed by `u32`
|
|
|
|
s.as_bytes()[3i32]; //~ERROR : the type `[u8]` cannot be indexed by `i32`
|
2014-04-02 03:39:26 +00:00
|
|
|
}
|