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
- Host: GitHub
- URL: https://github.com/dxrcy/nest-rs
- Owner: dxrcy
- Created: 2023-01-07T01:14:40.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-07T08:04:59.000Z (over 2 years ago)
- Last Synced: 2025-03-15T08:37:17.078Z (3 months ago)
- Language: Rust
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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]]");
}
```