cargo-version-sync
colorstring
doubter
doubter-impl
doubter-macros
finchers
finchers-core
finchers-derive
finchers-ext
finchers-http
struct Select<A, B>(Option<(A, B)>); | |
impl<A:Future, B:Future> Future for Select<A, B> { | |
type Output = Either<(A::Output, B), (A, B::Output)>; | |
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { | |
// omit | |
} | |
} |
cargo-version-sync
colorstring
doubter
doubter-impl
doubter-macros
finchers
finchers-core
finchers-derive
finchers-ext
finchers-http
#[macro_use] | |
extern crate tsukuyomi; | |
extern crate http; | |
use tsukuyomi::App; | |
use http::Method; | |
fn establish_db_connection(addr: &str) -> Pool { ... } | |
fn main() -> tsukuyomi::AppResult<()> { |
#[proc_macro_derive(SomeTrait)] | |
pub fn derive_some_trait_from_def(item: TokenStream) -> TokenStream { | |
let item: syn::DeriveInput = syn::parse(item).unwrap(); | |
... | |
} | |
#[proc_macro_attribute] | |
pub fn derive_some_trait_from_impl(attr: TokenStream, item: TokenStream) -> TokenStream { | |
let item: syn::ItemImpl = syn::parse(item).unwrap(); | |
... |
cargo-features = ["edition"] | |
[package] | |
name = "async-await-with-tokio" | |
version = "0.0.0" | |
publish = false | |
edition = "2018" | |
[[bin]] | |
name = "async-await" |
#![feature(test)] | |
extern crate test; | |
use test::Bencher; | |
use test::black_box; | |
use std::panic::catch_unwind; | |
fn foo_expect(n: i32) { | |
let a = bar(n).expect(&format!("n = {}", n)); | |
println!("{}", a); |
手続き的マクロやらcustom Derive周りを制御している周りの調査。 ほとんどソースファイルのコメントに書いていることなので新規性はない。
Rust は macro_rules!
で定義する宣言的 (declarative) なマクロの他に、手続き的 (procedural) なマクロを使用することが出来る。これは、通常のRustコードを用いてマクロ定義を行うものであり、次の利点を持っている。
asm!()
などで用いられている// format_args!("{0}{1}", a, b) | |
::std::fmt::Arguments::new_v1( | |
&["", ""], | |
&match (&a, &b) { | |
(__arg0, __arg1) => [ | |
::std::fmt::ArgumentV1::new(__arg0, ::std::fmt::Display::fmt), | |
::std::fmt::ArgumentV1::new(__arg1, ::std::fmt::Display::fmt), | |
], | |
}, | |
) |
#![feature(fmt_internals, rustc_private)] | |
extern crate fmt_macros; | |
use std::{fmt, io}; | |
#[derive(Default)] | |
struct ArgumentsBuilder<'a> { | |
pieces: Vec<&'a str>, | |
args: Vec<fmt::ArgumentV1<'a>>, |