From 1374e323a3692ed996650be448c1ea3fe122b207 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 25 Oct 2019 18:39:28 +0200 Subject: Add post: Release announcement for resiter v0.4.0 Signed-off-by: Matthias Beyer --- content/blog/2019-10-25-resiter-040.md | 65 ++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 content/blog/2019-10-25-resiter-040.md diff --git a/content/blog/2019-10-25-resiter-040.md b/content/blog/2019-10-25-resiter-040.md new file mode 100644 index 0000000..a50cc01 --- /dev/null +++ b/content/blog/2019-10-25-resiter-040.md @@ -0,0 +1,65 @@ +--- +title: "resiter v0.4.0" +date: "2019-10-25T21:45:40" +tags: ["library", "resiter"] +--- + +This is a short release announcement. `resiter` was released in version `v0.4.0` +earlier this day. + + +## v0.4.0 + +The changelog is rather minimal, as only one feature was added to the +library: The iterator extension `map_inner_ok_or_else()`. But lets start at the +beginning. + +If you have an `Result, E>>`, you often want to transform this +structure in the following way: + +1. If there is an `Err(_)`, keep it +1. If there is an `Ok(Some(_))`, unwrap the `Some(_)` +1. If there is an `Ok(None)` you want to get a nice `Err(_)` for this. + +So you often end up with code like this: + +```rust +object.and_then(|o| o.ok_or_else(|| do_something())) +``` + +This is not complicated and even convenient. But if you need to do this _all the +time_, it gets tiresome and is of course not easy to read if it appears all the +time. +It is way less complicated, though, to just do + +```rust +object.inner_ok_or_else(|| do_something()) +``` + +Easy, right? + +Now, if you have an `Iterator, E>>`, you need to apply +this function to each element: + +```rust +iter.map(|e| e.inner_ok_or_else(|| do_something())).collect::>() +``` + +for example. Ugly to read, right? So that's what the new feature does, it helps +you doing that without writing the above ugly thing: + +```rust +iter.map_inner_ok_or_else(|| do_something()).collect::>() +``` + + +## v0.3.0 + +(There was no post about 0.3.0, so here goes a short note) + +Before that there was a v0.3.0 release, which was entirely written by +[Dawid](https://dpc.pw/). Thank you a lot for that! +The changelog for that is a lot longer than the v0.4.0 changelog, it ships a lot +of awesome features, make sure to +[check it out](http://git.imag-pim.org/resiter/commit/?id=c576d2ec71625ca94cd27da76b6e9536c52d9114)! + -- cgit v1.2.3