doc: forward-port the conditions tutorial + fixup libstd example

Thanks to @huonw for some mentoring. :cake: