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
macro_rules! enum_with_str_repr { | |
($enum_name:ident { $($variant:ident => $str:expr),* }) => { | |
#[derive(PartialEq, PartialOrd, Copy, Clone, Eq, Ord, Hash, Debug)] | |
pub enum $enum_name { | |
$( | |
#[doc=$str] | |
$variant, | |
)* | |
} | |
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
[root] | |
name = "playground" | |
version = "0.1.0" | |
dependencies = [ | |
"serde_json 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | |
] | |
[[package]] | |
name = "dtoa" | |
version = "0.4.1" |
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
macro_rules! externs { | |
( $name:ident with macros, $($rest:tt)* ) => { | |
externs!($x with macros); | |
externs!($($rest)*); | |
}; | |
( $name:ident, $($rest:tt)* ) => { | |
externs!($name); | |
externs!($($rest)*); | |
}; | |
( $name:ident with macros ) => { |
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
macro_rules! graceful_hysteria { | |
($($stuff:tt)*) => { | |
{ | |
use std::io::Write; | |
let _ = writeln!(::std::io::stderr(), $($stuff)*); | |
::std::process::exit(1); | |
} | |
} | |
} |
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 fst<T1, T2>((t1, _t2): (T1, T2)) -> T1 { | |
t1 | |
} | |
fn snd<T1, T2>((_t1, t2): (T1, T2)) -> T2 { | |
t2 | |
} | |
fn main() { | |
let xs = vec![42, 43, 44, 45]; |
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
ARGS = $(filter-out $@,$(MAKECMDGOALS)) | |
MAKEFLAGS += --silent | |
PROJECTNAME = foobar | |
.PHONY: help | |
.DEFAULT_GOAL := help | |
help: | |
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' |
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::collections::BTreeMap; | |
use std::net::Ipv4Addr; | |
use std::thread; | |
use std::process::{Command, Stdio}; | |
fn main() { | |
let subnet: u8 = std::env::args() | |
.skip(1) | |
.next() | |
.unwrap_or("20".into()) |
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(dead_code)] | |
/// Create method to access field of sub-resource | |
/// | |
/// Similar to ActiveSupport's [`delegate`]. | |
/// | |
/// [`delegate`]: http://api.rubyonrails.org/classes/Module.html#method-i-delegate | |
/// | |
/// # Limitations | |
/// |
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
macro_rules! w { | |
($($x:ident)+) => { | |
vec![$(stringify!($x),)*] | |
} | |
} | |
#[test] | |
fn ident_vec() { | |
assert_eq!(w![foo bar baz], vec!["foo", "bar", "baz"]); | |
} |