SHARE
TWEET

Untitled

a guest Aug 17th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // mod settings {
  2. //     pub fn max_col() -> u16 { 11 }
  3. // }
  4.  
  5. fn main() {
  6.     // let long_str = "hello world\
  7.     //                 Lorem ipsum\
  8.     //                 dolor sit a\
  9.     //                 met, consec\
  10.     //                 tetur adipi\
  11.     //                 scing elit,\
  12.     //                 sed do eius\
  13.     //                 mod tempor \
  14.     //                 incididunt \
  15.     //                 ut\
  16.     //               ";
  17.     // let mut v1: Vec<char> = long_str.chars().collect();
  18.    
  19.     // v1.push('\n');
  20.     // v1.push('半');
  21.    
  22.     // // let v2 = b"hello, world".to_vec();
  23.     // // let v3 = b"hello, world!".to_vec();
  24.    
  25.     // println!("v1 len: {}", v1.len());
  26.     // println!("v1 index[10] \"{}\"", v1[10]);
  27.  
  28.     // fn idx(row: u16, col: u16) -> usize {
  29.     //     ((row * settings::max_col()) + col) as usize
  30.     // }
  31.  
  32.     // // eg. goto(1, 3)
  33.     // // let coords = (3, 5);
  34.     // let mut end_row = (v1.len() - 1) / settings::max_col() as usize;
  35.     // let mut end_col = (v1.len() - 1) % settings::max_col() as usize;
  36.     // println!("ending y: {}, ending x: {}", end_row, end_col);
  37.     // println!("goto char @ (0,5) : \"{}\"", v1[idx(0, 5)]);
  38.  
  39.     // v1.insert(idx(0, 5), ',');
  40.    
  41.     // println!("goto char @ (0,5): \"{}\"", v1[idx(0, 5)]);
  42.        
  43.     // end_row = (v1.len() - 1) / settings::max_col() as usize;
  44.     // end_col = (v1.len() - 1) % settings::max_col() as usize;
  45.     // println!("ending y: {}, ending x: {}", end_row, end_col);
  46.    
  47.     // println!("goto char @ end: \"{}\"",
  48.     //     v1[idx(end_row as u16, end_col as u16)]);
  49.        
  50.     // println!("char length: {}", '全'.len_utf8());
  51.     // println!("char length: {}", '角'.len_utf8());
  52.     // println!("char length: {}", '半'.len_utf8());
  53.    
  54.     // // let fix_array = ['半'; 264144];
  55.     // // println!("array memsize: {}", std::mem::size_of::<[u32; 262144]>());
  56.     // // 1056576
  57.    
  58.     let characters: Vec<u8> = "ho半".bytes().collect();
  59.     println!("vec<u8>: {:?}", characters);
  60.    
  61.     let str_chars = std::str::from_utf8(&characters);
  62.     println!("str: {}", str_chars.unwrap());
  63.    
  64.     // let mut vec_chars = str_chars.unwrap().chars();
  65.     // while let Some(c) = vec_chars.next() {
  66.     //     println!("char: {}", c);
  67.     // }
  68. }
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