daily pastebin goal
59%
SHARE
TWEET

Untitled

a guest Nov 9th, 2018 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use std::mem::replace;
  2. use std::io::Write;
  3.  
  4. fn foo(mut data: &mut [u8]) {
  5.     //data.write(&[1,2,3]);
  6.    
  7.     // но мне удобней так
  8.     data[0] =1;
  9.     data[1] = 2;
  10.     data[2] = 3;
  11.    
  12.     //а дальше у меня куча кода и надо пользоваться write
  13.    
  14.     let (a,b) = replace(&mut data, &mut []).split_at_mut(3);
  15.     data = b;
  16.     data.write(&[4,5,6]);
  17. }
  18.  
  19.  
  20. fn main() {
  21.     let mut d = [0,0,0,0,0,0];
  22.     foo(&mut d);
  23.     println!("d={:?}", d);
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top