Skip to content

Instantly share code, notes, and snippets.

View panicbit's full-sized avatar
:shipit:
Ship it

panicbit

:shipit:
Ship it
  • Dortmund, Germany, ᐰ
View GitHub Profile
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 {
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));
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
[]
@panicbit
panicbit / keybindings.json
Last active May 10, 2019 15:00
VSCode Settings
// 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"
},
struct OptionIter<I> {
iter: Option<I>,
}
impl<I> Iterator for OptionIter<I>
where
I: Iterator,
{
type Item = Option<I::Item>;
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();
}
uniforms {
projection: [4; fvec4]
}
inputs {
inpos,
inclr
}
outputs {
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());
}
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);