5 ms·
> And here's a toilet closure: |_| () > Called thusly because |_| () looks like a toilet. Pure poetry! Real talk though, this is a great introduction.
by nindalf 6y ago
> And here's a toilet closure: |_| ()
> Called thusly because |_| () looks like a toilet.
Pure poetry!
Real talk though, this is a great introduction.
- jerrre 6y agoI've been staring at this for a minute, but please help me seeing a toilet in this? Is it a top down view perhaps?
- kyrrewk 6y agotoilet seat up
- jackric 6y agowhich bit is the toilet seat?
- AlexSW 6y agoThe seat is to the right (the ( )) and the water tank (?) is on the left.
- matt_kantor 6y agoI made a visual: https://i.imgur.com/VgsDidE.jpg https://i.imgur.com/VgsDidE.jpg
- jackric 6y agoMuch appreciated!
- CJefferson 6y agoI often use the "owl" <(),()>, usually in Result<(),()>.
- brabel 6y agoWhy use a Result whose error type is empty?
- CJefferson 6y agoI should have said :) I am writing backtracking algorithms (think something like a Sudoku solver where we fill in values by guessing), and an 'Error' is when we can deduce the Sudoku cannot be filled in, so we have to backtrack. I find Rust's ? notation gives a very natural way of writing such algorithms. I don't care "why" filling in the Sudoku failed, particularly because the solver will typically fail millions of times a second, so I definately don't want constructing the error to be expensive in any way.
- jackric 6y agoI would suggest Option is the more semantic type to use for your situation - None indicating no valid solution on this path
- CJefferson 6y agoOh, today I learned the ? operator works with Option as well as Result! I might try that out, thanks.
- cesarb 6y agoIIRC, it didn't work with Option in the past, so you might have been correct when your code was written. The ? operator came originally from the try!() macro, which was specific to Result; unlike the macro, it was designed to be extensible through the still-unstable std::ops::Try trait, but IIRC that trait was initially implemented only for Result, and only later was extended to Option and a couple of others.
- fasterthanlime 6y agoIt's sometimes called a type-level boolean. Instead of trying to remember what true or false means, you have explicit variants associated with success or failure. (The underlying representation, including bit width, is the same)