Hi Alex,
I had seen an example at
http://static.rust-lang.org/doc/master/std/rt/io/file/fn.open.html which
closes the file at the end of a block.
I simply wants to open a file, checking if there is any error, for later
to can read it line by line until the end of file. I was wrong using the
Well, your program needs to handle the error somehow if there is one.
Something like this could work (though syntax may be wrong):
let file = match io::result(|| File::open(&Path::new("/some/path")) {
Ok(f) => f /* i.e. file is set to f */
Err(e) => fail!("cannot open file")
}
Alternativ
Out of curiosity, why not make File::open() return a Result<> instead of
Option<> like it does now? The current implementation already seems to be
matching against the result of fs_open() and returning None if the result
is Err(). So why the extra level of indirection and raising a condition in
tha
> Out of curiosity, why not make File::open() return a Result<> instead of
> Option<> like it does now?
This is a relic of I/O using conditions. The idea here is that if you
wanted to catch the condition, you can indeed catch it (and do
something appropriate). If you don't catch it then the task f
I am toying with a non-trivial Rust project to get a feel for the language.
There's a pattern I keep seeing in my code which isn't easy to express in
Rust. I wonder what the "right thing to do" is here.
The pattern is as follows. I have some container, which contains some
components of different t
On 11/3/13 10:11 PM, Oren Ben-Kiki wrote:
At any rate - is this something that makes sense in the Rust view?
If so, is there a chance of something like that being added (a
completely separate question :-)?
Two questions:
(1) In your proposal, do the cross-thread GC pointers have mutable
conte
On Mon, Nov 4, 2013 at 1:11 AM, Oren Ben-Kiki wrote:
> I am toying with a non-trivial Rust project to get a feel for the
> language. There's a pattern I keep seeing in my code which isn't easy to
> express in Rust. I wonder what the "right thing to do" is here.
>
> The pattern is as follows. I ha
On Mon, Nov 4, 2013 at 8:13 AM, Patrick Walton wrote:
> On 11/3/13 10:11 PM, Oren Ben-Kiki wrote:
>
>> At any rate - is this something that makes sense in the Rust view?
>> If so, is there a chance of something like that being added (a
>> completely separate question :-)?
>>
>
> Two questions:
>
On 11/3/13 10:19 PM, Oren Ben-Kiki wrote:
Because they don't allow cycles.
Aha. I personally think we should relax this restriction; it's pretty
onerous.
Patrick
___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust
Yes, using keys (or indices into a vector) is an option. There are two
problems with this.
It is pretty inefficient; one has to access the pool at any point, which
means doubling the sizes of the pointers (at least), probably more; One
needs a lot of unsafe code to allow mutating the pools; And th
Even if RC allowed cycles (I don't quite see how...) the whole thing
wouldn't be send-able, unless one uses ARC. But ARC has even more
performance penalties than RC... And doing cycle-supporting ARC across
tasks seems like pushing it - you might as well admit you are doing global
GC in the 1st plac
On 11/3/13 10:29 PM, Oren Ben-Kiki wrote:
Even if RC allowed cycles (I don't quite see how...) the whole thing
wouldn't be send-able, unless one uses ARC. But ARC has even more
performance penalties than RC... And doing cycle-supporting ARC across
tasks seems like pushing it - you might as well a
On Mon, Nov 4, 2013 at 1:29 AM, Oren Ben-Kiki wrote:
> Even if RC allowed cycles (I don't quite see how...) the whole thing
> wouldn't be send-able, unless one uses ARC. But ARC has even more
> performance penalties than RC... And doing cycle-supporting ARC across
> tasks seems like pushing it -
I've been looking at https://github.com/mozilla/rust/issues/6085 which
seems like it should be fairly simple to fix, however, the proposed
solution involves EnumSet from libextra.
Is it possible to use stuff from libextra within libstd? It seems to
me that it would set up a circular dependency, th
On Mon, Nov 4, 2013 at 2:10 AM, Martin DeMello wrote:
> I've been looking at https://github.com/mozilla/rust/issues/6085 which
> seems like it should be fairly simple to fix, however, the proposed
> solution involves EnumSet from libextra.
>
> Is it possible to use stuff from libextra within libst
15 matches
Mail list logo