An open API service indexing awesome lists of open source software.

https://github.com/dxrcy/nest-rs

Recursive vector nesting example in Rust
https://github.com/dxrcy/nest-rs

Last synced: 3 months ago
JSON representation

Recursive vector nesting example in Rust

Awesome Lists containing this project

README

        

# Recursive Vector Nesting Example

Just an example

```rs
use nest::{parse, Nest};

fn main() {
// Example text
// Note: No top-level brackets
let text = "1, [2, [3]], [4, 5]";

// Parse with items as strings
let strings: Nest = parse(text).unwrap();
assert_eq!(
format!("{:?}", strings),
r#"["1", ["2", ["3"]], ["4", "5"]]"#
);

// Map recursively to integers
let ints: Nest = strings.map(&|x| x.parse().unwrap());
assert_eq!(format!("{:?}", ints), "[1, [2, [3]], [4, 5]]");
}
```