This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug)] | |
struct ErrorA; | |
#[derive(Debug)] | |
struct ErrorB; | |
impl From<ErrorA> for ErrorB { | |
fn from(_: ErrorA) -> ErrorB { | |
ErrorB {} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let future = fut_a().from_err().and_then(|_| fut_b()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ErrorA; | |
struct ErrorB; | |
fn met_a() -> Result<(), ErrorA> { | |
Ok(()) | |
} | |
fn met_b() -> Result<(), ErrorB> { | |
met_a()?; | |
Ok(()) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl From<ErrorA> for ErrorB { | |
fn from(a: ErrorA) -> ErrorB { | |
ErrorB {} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(conservative_impl_trait)] | |
extern crate futures; | |
use futures::future::*; | |
struct ErrorA; | |
struct ErrorB; | |
fn fut_a() -> impl Future<Item = (), Error = ErrorA> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(conservative_impl_trait)] | |
extern crate futures; | |
use futures::future::*; | |
struct ExpectedError; | |
struct NotExpectedError; | |
fn something() -> Result<(), NotExpectedError> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Data.SqlClient; | |
class Program | |
{ | |
const string CONNECTION_STRING_PATTERN = "Data Source={0:S}; Integrated Security=true; Column Encryption Setting=enabled;Initial Catalog=alwaysEnc"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn process_file(noise_words: Arc<Vec<String>>, | |
separators: Arc<Vec<char>>, | |
collapser: Arc<Collapser>, | |
file_name: &Path) | |
-> Result<WordCounter, ProcessFileError> { | |
const THREADS: usize = 8; | |
let mut send_row_channels = Vec::new(); | |
let mut relinquish_wc_channels = Vec::new(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn super_dumb_thread2() -> Vec<u64> { | |
let (sx, rx) = channel(); | |
// here the thread steals the ownership | |
// of the send channel. That means it will | |
// drop the channel as soon as it finishes, | |
// signaling that no more data will be sent. | |
thread::spawn(move || { | |
for i in 0..100000000 { | |
if i % 10000 == 0 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn super_dumb_thread() -> Vec<u64> { | |
let t = thread::spawn(|| super_dumb_fn()); | |
t.join().unwrap() | |
} |