zeenix / gps-share

Utility to share your GPS device on local network
GNU General Public License v2.0
69 stars 9 forks source link

gps.rs: Use the ? operator instead of a match or try!() #1

Closed federicomenaquintero closed 7 years ago

federicomenaquintero commented 7 years ago

Protip: try!(foo) is equivalent to "foo?".

zeenix commented 7 years ago

@federicomenaquintero wow! thanks that does look much better and ? is indeed exactly what I needed. I did find the mention of ? operator in try! docs but it's hard to find docs on ? for obvious reasons. :)

I took the liberty of modifying your commit log, I hope you don't mind.

federicomenaquintero commented 7 years ago

Heh - the only reference I found to ? was in https://doc.rust-lang.org/reference.html#unary-operator-expressions - I saw some example code use it. I didn't really look in the try! docs. The "Error handling" chapter in the stable rust book doesn't mention it. Maybe the new book (which is awesome) will!

Feel free to modify anything you like in those commits.