«前の日記(2017-08-24) 最新 次の日記(2017-08-26)» 編集

ToDo:

  • 99 深呼吸して、おちけつ (~12/31 あと249日)
  • 98 毎日アウトプットを重きにおいた目標をたてる (~12/31 あと249日)
  • 97 買物は行動を変えるもの・ことに限る (~12/31 あと249日)
  • 96 合理的な行動はときに我慢を強いる(~12/31 あと249日)

ɥozɐʞıɥ


2017-08-25 明日から実家 [長年日記]

_ [Rust] トレイとトレイトオブジェクト

お勉強してます。

pub mod traitobject{

pub trait Foo{

fn method(&self) ->String;

}

impl Foo for u8 {

fn method(&self) -> String{

format!("Foo for U8: {}",self)

}

}

impl Foo for String{

fn method(&self) -> String{

format!("Foo for String: {}",self)

}

}

pub fn do_something<T: Foo> (x: T){

println!("Something = {}",x.method());

}

}

事前に宣言してmod名やtrailもそのまま使えるようにして

mod traitobject;

use traitobject::traitobject::Foo;

use traitobject::traitobject::do_something;

使っちゃいます。

fn main(){

do_something(127u8);

do_something("TraitObject Sample".to_string());

}

_ [Rust][][物欲] Manning | Rust in Action

In Actionシリーズきたー

Programming Rust: Fast, Safe Systems Developmentよりコスパはよさげ



2002|09|10|11|12|
2003|01|02|03|04|05|06|07|08|09|10|11|12|
2004|01|02|03|04|05|06|07|08|09|10|11|12|
2005|01|02|03|04|05|06|07|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|01|02|03|04|05|06|07|08|09|10|11|12|
2013|01|02|03|04|05|06|07|08|09|10|11|12|
2014|01|02|03|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|08|09|10|11|12|
2016|01|02|03|04|05|06|07|08|09|10|11|12|
2017|01|02|03|04|05|06|07|08|09|10|11|12|
2018|01|02|03|04|05|06|07|08|09|10|11|12|
2019|01|02|03|04|05|06|07|08|09|10|11|12|
2020|01|02|03|
«前の日記(2017-08-24) 最新 次の日記(2017-08-26)» 編集