Crates.io | chain_linq |
lib.rs | chain_linq |
version | 0.1.3 |
source | src |
created_at | 2021-11-14 23:31:20.110765 |
updated_at | 2021-11-20 22:14:10.31949 |
description | An implementation of .NET's LINQ in rust as a declarative macro. |
homepage | |
repository | https://github.com/PROMETHIA-27/chain_linq |
max_upload_size | |
id | 481906 |
size | 14,831 |
This crate is an implementation of .NET's LINQ query syntax in rust as a declarative macro. The declarative macro is generated by another declarative macro, specifically the branching_parser from my other crate, big_mac.
Available statements closely mirror standard LINQ operations; notably join is missing, as I was unable to find equivalent functionality from iterators.
Generally, each statement maps to an iterator method; here is a list of them, with a description and equivalent method if present:
REQUIRES ITERTOOLS:
For more explanation of how LINQ works, check Microsoft's docs here
Also useful: Keyword breakdowns
use chain_linq::linq;
let xs = [(3, 1), (2, 2), (1, 3)];
let x = linq!(
from (x, y) in xs
let z = x + y
select z into zs
from z in zs
select z * 2
);
use chain_linq::linq;
let xss = [vec!(27, 13, 12), vec!(69), vec!(76, 7, 420)];
let x = linq!(
from xs in xss
group xs by xs.len() into gs
from iter in gs
from x in iter
collect x + 1 as Vec<i32>
);
use chain_linq::linq;
let xss = [vec!(27, 13, 12), vec!(69), vec!(76, 7, 420)];
let x = linq!(
from xs in xss
from x in xs.into_iter().rev()
collect x as Vec<i32>
);