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::convert::Infallible; | |
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)); |
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 val = Some(10); | |
//let val = None; | |
let z = maybe_add_four(val); | |
println!("{:?}", z) | |
} | |
fn maybe_add_four(y: Option<i32>) -> Option<i32> { | |
let ret = y.map(|x| x + 4); | |
assert_eq!(y, Some(10)); |
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!"); | |
} |
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 A { | |
a: usize, | |
b: &'static str, | |
} | |
const LIST: [A; 2] = [ | |
A { a: 1, b: "hello" }, A { a: 2, b: "w" }, | |
]; |
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 A { | |
a: usize, | |
b: &'static str, | |
} | |
const LIST: [A; 1] = [ | |
A { a: 1, b: "hello" } | |
]; |
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(extern_prelude)] | |
extern crate serde; // 1.0.68 | |
#[macro_use] | |
extern crate serde_derive; // 1.0.68 | |
use std::collections::HashMap; | |
use serde::*; | |
use std::fmt::{Display, Formatter}; | |
use serde::ser::{Serialize, Serializer, SerializeSeq, SerializeMap}; |
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::os::raw::c_int; | |
use std::sync::mpsc::sync_channel; | |
use std::{cmp, slice}; | |
use reqwest::{Client, Method, StatusCode}; | |
use tokio::runtime::Handle; | |
pub struct Context<'a> { | |
client: &'a Client, | |
endpoint: &'a str, |
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 core::mem::MaybeUninit; | |
use core::ptr::NonNull; | |
use core::marker::PhantomData; | |
use core::cmp::Ordering; | |
const MAX_N: usize = 16; | |
struct InternalNode<T> { | |
leaf: LeafNode<T>, | |
children: [BoxedNode<T>; MAX_N], |
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!"); | |
} |
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 PrintInDrop(&'static str); | |
impl Drop for PrintInDrop { | |
fn drop(&mut self) { | |
println!("{}", self.0); | |
} | |
} | |
fn bar(_: &PrintInDrop) -> PrintInDrop { | |
PrintInDrop("ret") |