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 iterator_ref(opt: &Option<bool>) -> Box<Iterator<u8>> { | |
match opt { | |
&Some(_) => box [1u8].iter().map(|n| *n) as Box<Iterator<u8>>, | |
&None => box [0u8].iter().map(|n| *n) as Box<Iterator<u8>>, | |
} | |
} | |
fn main() { | |
let mut myref = iterator_ref(&Some(true)); |
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 serialize_iter<'a>(&'a self) -> SerializeIter<'a> { | |
/* | |
println!("serialize opt {:} as {:}", self.is_some(), | |
(match self { | |
&Some(ref dat) => SerializeIter { | |
data_iter: Some(box [1u8].iter().map(|n| *n) as Box<Iterator<u8>>), | |
sub_iter_iter: box vec![ dat as &Serializable ].move_iter(), | |
sub_iter: None, | |
sub_started: false | |
}, |
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 serialize_iter<'a>(&'a self) -> SerializeIter<'a> { | |
/* | |
println!("serialize opt {:} as {:}", self.is_some(), | |
(match self { | |
&Some(ref dat) => SerializeIter { | |
data_iter: Some(box [1u8].iter().map(|n| *n) as Box<Iterator<u8>>), | |
sub_iter_iter: box vec![ dat as &Serializable ].move_iter(), | |
sub_iter: None, | |
sub_started: false | |
}, |
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::io::{IoResult, InvalidInput, standard_error}; | |
/// Serialization trait | |
trait Serial { | |
fn deserialize<I: Iterator<u8>>(iter: I) -> IoResult<Self>; | |
} | |
/// Serialization for Option<Serial> | |
impl<T:Serial> Serial for Option<T> { |
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
// Rust Bitcoin Library | |
// Written in 2014 by | |
// Andrew Poelstra <apoelstra@wpsoftware.net> | |
// | |
// To the extent possible under law, the author(s) have dedicated all | |
// copyright and related and neighboring rights to this software to | |
// the public domain worldwide. This software is distributed without | |
// any warranty. | |
// | |
// You should have received a copy of the CC0 Public Domain Dedication |
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
// Rust Bitcoin Library | |
// Written in 2014 by | |
// Andrew Poelstra <apoelstra@wpsoftware.net> | |
// | |
// To the extent possible under law, the author(s) have dedicated all | |
// copyright and related and neighboring rights to this software to | |
// the public domain worldwide. This software is distributed without | |
// any warranty. | |
// | |
// You should have received a copy of the CC0 Public Domain Dedication |
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
// Rust Bitcoin Library | |
// Written in 2014 by | |
// Andrew Poelstra <apoelstra@wpsoftware.net> | |
// | |
// To the extent possible under law, the author(s) have dedicated all | |
// copyright and related and neighboring rights to this software to | |
// the public domain worldwide. This software is distributed without | |
// any warranty. | |
// | |
// You should have received a copy of the CC0 Public Domain Dedication |
NewerOlder