Rust

filter_map, find & any

Në shqip përdoret i njëjti emër.

ShpjegimiSQ

filter_map() filtron dhe transformon në një hap (mban vetëm Some); find() kthen elementin e parë që përputhet; any() dhe all() kontrollojnë kushte; position() gjen indeksin.

EnglishEN

filter_map() filters and transforms in one step (keeping only Some); find() returns the first matching item; any() and all() test conditions; position() finds the index.

Si ta mendosh

Si një sitë që edhe i pastron frutat që lë të kalojnë.

Lexoje në anglisht

Like a sieve that also cleans the fruit it lets through.

Shembull kodirust

let numrat: Vec<i32> = ["1", "x", "3"].iter().filter_map(|s| s.parse().ok()).collect();
let ka_te_dobet = notat.iter().any(|&n| n < 5);

Terma të lidhur