Skip to content

Instantly share code, notes, and snippets.

@fujitayy
fujitayy / playground.rs
Created December 26, 2018 07:05 — forked from rust-play/playground.rs
Code shared from the Rust Playground
//! newtype patternで簡単に元の型と同等の機能を提供するには?
use itertools::Itertools;
macro_rules! impl_as {
($newtype:ty, $basetype:ty, $field:tt, $method:ident) => {
impl $newtype {
fn $method(&self) -> &$basetype {
&self.$field
}
@fujitayy
fujitayy / playground.rs
Created January 8, 2019 08:09 — forked from rust-play/playground.rs
Code shared from the Rust Playground
//! この方法の方でCakeパターンをするとintellij-rustでの補完が効くケースが多い。
type Error = Box<std::error::Error>;
#[derive(Debug, Clone, Copy)]
struct EmployeeId(u64);
#[derive(Debug)]
struct Employee {
id: EmployeeId,
@fujitayy
fujitayy / playground.rs
Created January 17, 2019 01:24 — forked from rust-play/playground.rs
Code shared from the Rust Playground
pub mod person {
use std::marker::PhantomData;
#[derive(Debug)]
pub struct Person {
name: String,
age: u8,
}
impl Person {