Advertisement
cwchen

[Rust] Storing data into a slice with indexs.

Aug 22nd, 2017
727
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.19 KB | None | 0 0
  1. fn main() {
  2.     let slice = &mut [1, 2, 3];
  3.  
  4.     // Write data into slice
  5.     slice[1] = 99;
  6.  
  7.     assert_eq!(slice[0], 1);
  8.     assert_eq!(slice[1], 99);
  9.     assert_eq!(slice[2], 3);
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement