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 counter1 = Counter { name: "C1", counter: 3 }; | |
let counter2 = Counter { name: "C2", counter: 5 }; | |
let joined = join(counter1, counter2); | |
block_on(joined); | |
} | |
fn block_on(mut future: impl Future) { | |
loop { |
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::{error::Error, net::SocketAddr, time::{Instant, Duration}}; | |
use hyper::{Body, Request, Response, Server}; | |
use hyper::{body::Bytes, service::{make_service_fn, service_fn}}; | |
use futures::prelude::*; | |
use tokio::time::delay_for; | |
#[tokio::main] | |
async fn main() { | |
let addr = SocketAddr::from(([0, 0, 0, 0], 7777)); |
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::future::Future; | |
use std::pin::Pin; | |
use std::task::{Poll, Context, Waker, RawWaker, RawWakerVTable}; | |
use std::sync::mpsc::{sync_channel, Receiver}; | |
use tokio::task::yield_now; | |
macro_rules! gen_iter { | |
( | |
@EMIT $yield_tx:ident | |
[] |
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
// Place your key bindings in this file to overwrite the defaults | |
[ | |
{ | |
"key": "ctrl+tab", | |
"command": "workbench.action.nextEditor" | |
}, | |
{ | |
"key": "ctrl+pagedown", | |
"command": "-workbench.action.nextEditor" | |
}, |
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 OptionIter<I> { | |
iter: Option<I>, | |
} | |
impl<I> Iterator for OptionIter<I> | |
where | |
I: Iterator, | |
{ | |
type Item = Option<I::Item>; |
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
let mut head = Node::new(vec[0].clone()); | |
let mut current_head: &mut Node<T> = &mut head; | |
for &next in &vec[1..] { | |
let moved_head = current_head; // Takes the mutable reference away from current_head | |
moved_head.right = Some(Box::new(Node::new(next.clone()))); | |
current_head = moved_head.right.as_mut().unwrap(); | |
} |
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
uniforms { | |
projection: [4; fvec4] | |
} | |
inputs { | |
inpos, | |
inclr | |
} | |
outputs { |
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
extern crate cidr; | |
use cidr::{Ipv4Inet,Inet}; | |
fn main() { | |
let ip = "10.61.3.123".parse().unwrap(); | |
let ip = Ipv4Inet::new(ip, 24).unwrap(); | |
println!("{}", ip.network()); | |
} |
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
extern crate cidr; | |
extern crate bitstring; | |
use cidr::{Ipv4Cidr,Cidr}; | |
use bitstring::BitString; | |
fn main() { | |
let ip = "10.61.3.123".parse().unwrap(); | |
let mut net = Ipv4Cidr::new_host(ip); | |
net.clip(24); |
NewerOlder