View playground.rs
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 mock<T: Into<String>, I: IntoIterator<Item = T>>(_: I) {} | |
struct Merchant<'a> { | |
name: &'a str, | |
billing_portal: &'a str, | |
billing_period: &'a str, | |
stripe_id: Option<&'a str>, | |
} | |
fn merchant() -> Merchant { unimplemented!(); } |
View playground.rs
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
use std::fmt::Display; | |
fn do_things<T>(a: T, b: T) where | |
T: IntoIterator, | |
T::Item: Display { | |
for (e,f) in a.into_iter().zip(b.into_iter()) { | |
println!("{} {}", e, f); | |
} | |
} |
View playground.rs
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
#![allow(unused)] | |
use std::collections::HashMap; | |
use std::io; | |
struct PhoneEntry { | |
name: String, | |
phone: String, | |
} | |
impl PhoneEntry { |
View playground.rs
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 Inner { | |
a: A, | |
} | |
impl Inner { | |
fn fun(&mut self) { | |
self.a.something(); | |
} | |
fn fun2(&mut self, outer: &Arc<Outer>) { | |
self.a.something2(outer.b); |
View playground.rs
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
use rusqlite::{Connection, Result}; | |
fn main() -> Result<()> { | |
let conn = Connection::open("data.sqlite")?; | |
let name = ""; | |
let stripe_id = None; | |
conn.execute( | |
"INSERT INTO merchants (name, stripe_id) VALUES (?, ?)", |
View playground.rs
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() { | |
println!("Hello, world!"); | |
} |
View playground.rs
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() { | |
println!("Hello, world!"); | |
} |
View playground.rs
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
use std::net::SocketAddr; | |
use hyper::{Body, http, Request, Response, Server, StatusCode}; | |
use hyper::service::{make_service_fn, service_fn}; | |
#[tokio::main] | |
async fn main() { | |
let addr = SocketAddr::from(([127, 0, 0, 1], 3030)); | |
let make_svc = make_service_fn(|_conn| async { |
View playground.rs
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
use lazy_static; // 1.4.0 | |
use std::collections::HashMap; | |
#[derive(Copy, Clone, Debug)] | |
pub struct Server {} | |
lazy_static::lazy_static! { | |
static ref SERVER1: Server = Server {}; | |
static ref SERVER2: Server = Server {}; | |
View playground.rs
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
use std::process::{Command, Stdio}; | |
fn main() { | |
let mut rev = Command::new("rev") | |
.stdin(Stdio::piped()) | |
.stdout(Stdio::inherit()) | |
.stderr(Stdio::inherit()) | |
.spawn() | |
.expect("rev failed to spawn"); |
NewerOlder