Last active
November 29, 2025 21:10
-
-
Save mcsee/7d729029618f1088697f9fec70a8ba43 to your computer and use it in GitHub Desktop.
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn load_and_validate(max: usize) -> Result<Vec<Feature>, String> { | |
| let raw: Vec<Result<Feature, Error>> = load_features_from_db(); | |
| if raw.len() > max { | |
| return Err(format!( | |
| "too many features: {} > {}", | |
| raw.len(), max | |
| )); | |
| } | |
| Ok(raw.into_iter() | |
| .filter_map(|r| r.ok()) | |
| .collect()) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment