(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| #![feature(non_ascii_idents)] | |
| fn main() { | |
| std::env::args().nth(1) | |
| .ok_or(format!("Usage: {} FILE", std::env::args().next().unwrap())) // File name | |
| .and_then(|filename| { | |
| std::fs::File::open(&filename) | |
| .map_err(|e| (&e as &std::error::Error).description().to_string()) | |
| }).map(|f| (f, String::new())) | |
| .map(|(mut f, mut s)| ((&mut f as &mut std::io::Read).read_to_string(&mut s), s)) |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| //! Chain macro in Rust | |
| //! | |
| //! A typical usage is to avoid nested match expressions. | |
| //! | |
| //! Supports: | |
| //! - Pattern matching | |
| //! - Or expressions (A | B => ...) | |
| //! - Guarded statements (x if <cond> => ...) | |
| //! - Implicit else (requires all arms to return same type) |
| import android.app.Activity; | |
| import android.app.Service; | |
| import android.content.BroadcastReceiver; | |
| import android.content.Context; | |
| import android.content.Intent; | |
| import android.content.IntentFilter; | |
| import android.os.Bundle; | |
| import android.os.IBinder; | |
| import android.support.v4.content.LocalBroadcastManager; |