Skip to content

Instantly share code, notes, and snippets.

🦄
horsin' around

Saoirse Shipwreckt withoutboats

🦄
horsin' around
View GitHub Profile
View gist:81f8185849a032de48aa2be126672d18
extern crate futures;
use std::str::FromStr;
use futures::{IntoFuture, Future};
fn foo<'a, T: Foo>(string: &'a str) -> Box<Future<Item = T, Error = ()> + 'a> {
Box::new(string.parse().into_future()
.or_else(|_| Err(()))
.and_then(|id| Foo::from_id(&id)))
View futures.rs
extern crate futures;
use futures::Future;
pub trait Foo: 'static {
fn parse(string: String) -> Box<Future<Item = Self, Error = ()>>;
}
pub trait Bar: 'static {
type Id: Foo;
View gist:65f811d678bede340f8a1d05320be47d
This document is the result of conversations that came out of this tweet: https://twitter.com/withoutboats/status/814201265575981056
# Rust's module system is too confusing
Empirically, very many new users of Rust are confused by Rust's module system. This is unfortunate: Rust's module system is not particularly innovative or powerful; it is intended only to provide fairly standard privacy and namespacing support. Too much of new users' attention is being pulled by this system as it exists today.
This document presents an hypothesis of the cause of the confusion, and an attempt to mitigate that confusion by instituting a practice that is more similar to mainstream languages. We believe this problem is caused by the confluence of a several well-motivated design decisions that have created a very unusual system, and the solution is to require less declarations by leveraging ambient information in a manner more similar to how other languages' module systems work.
## Rust requires users to build an explicit
View modules.md

This document is the result of conversations that came out of this tweet: https://twitter.com/withoutboats/status/814201265575981056

Rust's module system is too confusing

Empirically, very many new users of Rust are confused by Rust's module system. This is unfortunate: Rust's module system is not particularly innovative or powerful; it is intended only to provide fairly standard privacy and namespacing support. Too much of new users' attention is being pulled by this system as it exists today.

This document presents an hypothesis of the cause of the confusion, and an attempt to mitigate that confusion by instituting a practice that is more similar to mainstream languages. We believe this problem is caused by the confluence of a several well-motivated design decisions that have created a very unusual system, and the solution is to require less declarations by leveraging ambient information in a manner more similar to how other languages' module systems work.

Rust requires users to build an explicit

View gist:bd91286a1c04f170532f1f83bd5ca513
#[macro_use] extern crate cargonauts;
use cargonauts::futures::{Future, future};
use cargonauts::resources::{Resource, Environment, Error};
use cargonauts::methods::Get;
use cargonauts::formats::Debug;
routes! {
resource Echo {
method Get in Debug;
View cargonauts_echo.rs
#[macro_use] extern crate cargonauts;
use cargonauts::futures::{Future, future};
use cargonauts::resources::{Resource, Environment, Error};
use cargonauts::methods::Get;
use cargonauts::formats::Debug;
routes! {
resource Echo {
method Get in Debug;
View cargonauts_echo.rs
#[macro_use] extern crate cargonauts;
use cargonauts::futures::{Future, future};
use cargonauts::resources::{Resource, Environment, Error};
use cargonauts::methods::Get;
use cargonauts::formats::Debug;
routes! {
resource Echo {
method Get in Debug;
@withoutboats
withoutboats / constraint-kinds.md
Last active Mar 16, 2018
Constraint Kinds in Rust
View constraint-kinds.md

Notes on adding Constraint Kinds to Rust

Background: Constraint Kinds

a trait can be thought of as a type operator generating a "constraint" - what in Rust would usually be called a bound. For example:

// Declares a new item `Foo` with kind `type -> constraint`
trait Foo { }
@withoutboats
withoutboats / net-wg-slides.md
Created Mar 29, 2018
net wg presentation slide data
View net-wg-slides.md

Network services WG


Network services WG

  1. Async IO
  2. Library support for network services

View async-methods.md

Goal:

trait MyTrait {
    async fn foo(&self) -> i32;
}

impl MyTrait for MyType {
    async fn foo(&self) -> i32 {
       /* ... * /
You can’t perform that action at this time.