Skip to content

Instantly share code, notes, and snippets.

View MindFlavor's full-sized avatar

Francesco Cogno MindFlavor

View GitHub Profile
#[derive(Debug)]
struct ErrorA;
#[derive(Debug)]
struct ErrorB;
impl From<ErrorA> for ErrorB {
fn from(_: ErrorA) -> ErrorB {
ErrorB {}
}
}
fn main() {
let future = fut_a().from_err().and_then(|_| fut_b());
}
struct ErrorA;
struct ErrorB;
fn met_a() -> Result<(), ErrorA> {
Ok(())
}
fn met_b() -> Result<(), ErrorB> {
met_a()?;
Ok(())
}
impl From<ErrorA> for ErrorB {
fn from(a: ErrorA) -> ErrorB {
ErrorB {}
}
}
#![feature(conservative_impl_trait)]
extern crate futures;
use futures::future::*;
struct ErrorA;
struct ErrorB;
fn fut_a() -> impl Future<Item = (), Error = ErrorA> {
#![feature(conservative_impl_trait)]
extern crate futures;
use futures::future::*;
struct ExpectedError;
struct NotExpectedError;
fn something() -> Result<(), NotExpectedError> {
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";
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();
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 {
fn super_dumb_thread() -> Vec<u64> {
let t = thread::spawn(|| super_dumb_fn());
t.join().unwrap()
}