The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Convert Lines Of Characters Into A Vec Of Vecs In Rust

TODO: Pull subtitle into page object
Code
fn main() {
  let cases = vec![
    (
      "abcd\nefgh",
      vec![vec!['a', 'b', 'c', 'd'], vec!['e', 'f', 'g', 'h']]
    )
  ];

  cases.iter().for_each(|case| {
    let left = split_line_chars(case.0);
    dbg!(&left);
    assert_eq!(left, case.1);
  });

}

fn split_line_chars(source: &str) -> Vec<Vec<char>> {
  let lines = source.lines();
  lines.map(|line| line.chars().map(|c| c).collect()).collect()
}
Results
[neopolitan_code_run:12] &left = [
    [
        'a',
        'b',
        'c',
        'd',
    ],
    [
        'e',
        'f',
        'g',
        'h',
    ],
]

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Convert Lines Of Characters Into A Vec Of Vecs In Rust

-- code
-- rust


fn main() {
  let cases = vec![
    (
      "abcd\nefgh",
      vec![vec!['a', 'b', 'c', 'd'], vec!['e', 'f', 'g', 'h']]
    )
  ];

  cases.iter().for_each(|case| {
    let left = split_line_chars(case.0);
    dbg!(&left);
    assert_eq!(left, case.1);
  });

}

fn split_line_chars(source: &str) -> Vec<Vec<char>> {
  let lines = source.lines();
  lines.map(|line| line.chars().map(|c| c).collect()).collect()
}

-- results/

[neopolitan_code_run:12] &left = [
    [
        'a',
        'b',
        'c',
        'd',
    ],
    [
        'e',
        'f',
        'g',
        'h',
    ],
]

-- /results


-- categories
-- Rust 

-- metadata
-- date: 2023-12-13 21:05:30
-- id: 2zvunuga
-- site: aws
-- type: post
-- status: published