«前の日記(2017-07-25) 最新 次の日記(2017-07-29)» 編集

ToDo:

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

ɥozɐʞıɥ


2017-07-27 LinkedListっぽい? [長年日記]

_ [買物][] イヤな自分を1日で変える脳ストレッチ

このところの疲れからの脱却を狙っています

_ [Rust]Linked List

本当はgenericsにしたかったのだがcompile error が取れない。

#[derive(Debug)]

struct LinkedList {

val: &'static str,

next: Option

}

pub fn chain(){

let mut root = LinkedList{val: "Taro", next: None};

root.next = Some(Box::new(LinkedList{val: "Jiro", next: None}));

println!("{:?}",root);

}

BoxにしないとLinkedListをメンバーにもたせると

--> src/linkedlist.rs:3:5

|

3 | struct LinkedList {

| ^^^^^^^^^^^^^^^^^ recursive type has infinite size

|

= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `linkedlist::foo::LinkedList` representable

てな感じで無限ループでsizeが取れないのでcompile error になるそうです。



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-07-25) 最新 次の日記(2017-07-29)» 編集