English
I've pushed v0.2.0 for wibr — fully customizable constructors and fallible iterator adapters. MakeFull derive: a step up from Make. #[Fn(name)] names the constructor whatever you want. #[Extern(name: Type)] adds an argument that isn't a struct field at all, only used inside setup code. #[Code({ ... })] runs arbitrary code before the struct is built — on the struct itself or on a specific field, doesn't matter, they all run in order. #[Functional] fields aren't arguments and have no default — their value comes from a Code block, matched by variable name. TryIterator: try_map and try_filter_map work like map/filter_map, but the closure returns a Result, and the walk stops at the first error instead of panicking or silently dropping it. Pull the error back out with .take_err() (error + iterator) or .take_okk() (Result<iterator, error>), or skip straight to .try_collect::() for Result<C, error> in one call. TryRetainable: try_retain — same as retain, except the predicate returns Result<bool, E>, so you can use ? right inside it instead of unwrapping by hand. Same rule as v0.1.0: nothing implicit, nothing you couldn't write yourself, just less of it to write.
Русский
Выкатил v0.2.0 для wibr — полностью настраиваемые конструкторы и фейлящиеся адаптеры итераторов. Дерайв MakeFull: шаг вперёд от Make. #[Fn(name)] называет конструктор как хочешь. #[Extern(name: Type)] добавляет аргумент, который вообще не является полем структуры, нужен только внутри кода инициализации. #[Code({ ... })] выполняет произвольный код перед сборкой структуры — хоть на самой структуре, хоть на конкретном поле, неважно, выполняются по порядку. Поля #[Functional] не становятся аргументами и не имеют значения по умолчанию — их значение приходит из блока Code, сопоставляется по имени переменной. TryIterator: try_map и try_filter_map работают как map/filter_map, но замыкание возвращает Result, и обход останавливается на первой ошибке вместо паники или тихого выбрасывания. Достать ошибку обратно можно через .take_err() (ошибка + итератор) или .take_okk() (Result<итератор, ошибка>), либо сразу .try_collect::() для Result<C, ошибка> одним вызовом. TryRetainable: try_retain — то же самое, что retain, только предикат возвращает Result<bool, E>, поэтому внутри него можно прямо использовать ? вместо ручного unwrap. Правило то же, что и в v0.1.0: ничего неявного, ничего такого, что вы не написали бы сами, просто меньше писанины.
GitHub:GitHub - Honami333/Wibr: What ought to be in Rust by default, but the developers decided otherwise. Micro syntactic sugar just for you. · GitHub
Crates.io: crates.io: Rust Package Registry
Telegram Channel: [Telegram: View @cat_garden_news](Telegram: View @cat_garden_news)