Full source code:
extern mod std;
extern mod extra;
use std::{task, io};
use extra::flatpipes;
fn main() {
let (port, chan) = flatpipes::serial::pipe_stream();
do task::spawn || {
let value = @[1, 2, 3, 4, 5];
chan.send(value)
}
let val = port.recv();
io::println(fmt!("%?", val));
/*let (port, chan) = flatpipes::serial::pipe_stream();*/
/*do task::spawn || {*/
/*let val = port.recv();*/
/*io::println(fmt!("Value: %?", val));*/
/*}*/
/*let value = @[1, 2, 3, 4, 5];*/
/*chan.send(value);*/
}
And compiler output:
astavonin:/Users/../rust: rustc -v
rustc 0.7
host: x86_64-apple-darwin
astavonin:/Users/../rust: rustc test.rs
warning: no debug symbols in executable (-arch x86_64)
But, If you uncomment second block, you'll have next error:
test.rs:19:18: 19:22 error: cannot capture variable of type
`extra::flatpipes::FlatPort<@[int],extra::flatpipes::flatteners::DeserializingUnflattener<extra::ebml::reader::Decoder,@[int]>,extra::flatpipes::bytepipes::PipeBytePort>`,
which does not fulfill `Send`, in a bounded closure
test.rs:19 let val = port.recv();
^~~~
test.rs:19:18: 19:22 note: this closure's environment must satisfy `Send`
test.rs:19 let val = port.recv();
^~~~
error: aborting due to previous error
Best regards,
Alexander.
2013/7/8 Josh Leverette <[email protected]>
> I'm having difficulty compiling even the first sample. Nothing I do can
> convince my rust 0.7 compiler of the existence of flatpipes... but I'm new
> to this whole thing anyways.
>
> The one thing that jumps out at me: should the second example have "||"
> after the word 'spawn' in the do statement? i.e. do task::spawn || {
> instead of do task::spawn {
>
> My understanding is that the empty vertical bars indicate an empty
> argument name list, so it should have no negative effect on the code, but
> it's worth testing, I suppose. What "use" or "extern mod" statements did
> you place at the top of the Rust files in order to get them to compile? I
> may not know much, but I'd like to learn, and I'd like to help when I can.
>
> According to the tutorial, both chan and port should be sendable types
> that can be transferred to the task's closure.
>
> I'm interested in what's going on here as well.
>
>
> On Sun, Jul 7, 2013 at 1:49 PM, Alexander Stavonin
> <[email protected]>wrote:
>
>> There are two fragments of codes first one can be compiled without any
>> errors:
>>
>> let (port, chan) = flatpipes::serial::pipe_stream();
>> do task::spawn || {
>> let value = @[1, 2, 3, 4, 5];
>> chan.send(value)
>> }
>> let val = port.recv();
>> io::println(fmt!("%?", val));
>>
>> But second one provides errors:
>>
>> let (port, chan) = flatpipes::serial::pipe_stream();
>> do task::spawn {
>> let val = port.recv();
>> io::println(fmt!("Value: %?", val));
>> }
>> let value = @[1, 2, 3, 4, 5];
>> chan.send(value);
>>
>> tmp.rs:19:18: 19:22 error: value has non-owned type
>> `extra::flatpipes::FlatPort<@[int],extra::flatpipes::flatteners::DeserializingUnflattener<extra::ebml::reader::Decoder,@[int]>,extra::flatpipes::bytepipes::PipeBytePort>`
>> tmp.rs:19 let val = port.recv();
>> ^~~~
>>
>> From my point of view, both fragments are equivalent, so, is it
>> compiler error or my misunderstanding?
>>
>> Kind regards,
>> Alexander
>>
>>
>> _______________________________________________
>> Rust-dev mailing list
>> [email protected]
>> https://mail.mozilla.org/listinfo/rust-dev
>>
>>
>
>
> --
> Sincerely,
> Josh
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev