Gossamer
Goroutines, garbage collection, and forward pipes — on a Rust-flavoured surface that compiles fast.
Natural functional flow with forward pipes
fn double(x: i64) -> i64 { x * 2 }
fn add(a: i64, b: i64) -> i64 { a + b }
fn clamp(lo: i64, hi: i64, x: i64) -> i64 {
if x < lo { lo } else if x > hi { hi } else { x }
}
fn main() {
let n = 3i64
|> double
|> add(10i64)
|> clamp(0i64, 100i64)
println("answer:", n)
}
Spin up a web server
use std::http
struct App { }
impl http::Handler for App {
fn serve(&self, request: http::Request) -> Result<http::Response, http::Error> {
Ok(http::Response::text(200, "hello, gossamer".to_string()))
}
}
fn main() -> Result<(), http::Error> {
http::serve("0.0.0.0:8080".to_string(), App { })
}