[rust-dev] Mutable files

2014-07-20 Thread David Henningsson
Hi, Consider these two examples: 1) let mut file = File::open(filename); file.read(buf); 2) let file = File::open(filename); let mut reader = BufferedReader::new(file); reader.read(buf); My question is: in example 2, why doesn't BufferedReader need file to be mutable? After all,

Re: [rust-dev] Mutable files

2014-07-20 Thread David Henningsson
On 2014-07-21 03:33, Patrick Walton wrote: On 7/20/14 6:29 PM, David Henningsson wrote: Hi, Consider these two examples: 1) let mut file = File::open(filename); file.read(buf); 2) let file = File::open(filename); let mut reader = BufferedReader::new(file); reader.read(buf); My question

Re: [rust-dev] Mutable files

2014-07-20 Thread David Henningsson
errors in users of that library that expected the other type. But if the compiler is guaranteed to catch all such errors even with today's handling, maybe that is not too much to worry about. On Sun, Jul 20, 2014 at 7:39 PM, David Henningsson di...@ubuntu.com mailto:di...@ubuntu.com wrote

Re: [rust-dev] Mutable files

2014-07-21 Thread David Henningsson
On 2014-07-21 06:06, Patrick Walton wrote: On 7/20/14 9:04 PM, Patrick Walton wrote: On 7/20/14 8:12 PM, David Henningsson wrote: Cool, thanks for the answer. These restrictions seem somewhat complex. They are required. Otherwise we would end up with a C++-like situation where copies end

Re: [rust-dev] Opt-In Built-In Traits (was: Mutable files)

2014-07-23 Thread David Henningsson
On 2014-07-21 19:17, Patrick Walton wrote: On 7/21/14 8:49 AM, Tobias Müller wrote: Patrick Walton pcwal...@mozilla.com wrote: On 7/20/14 8:12 PM, David Henningsson wrote: From a language design perspective, maybe it would be more intuitive to have different syntaxes for copy and move

Re: [rust-dev] Opt-In Built-In Traits

2014-07-25 Thread David Henningsson
On 2014-07-24 16:30, Kevin Ballard wrote: On Wed, Jul 23, 2014, at 12:52 PM, David Henningsson wrote: On 2014-07-21 19:17, Patrick Walton wrote: On 7/21/14 8:49 AM, Tobias Müller wrote: Patrick Walton pcwal...@mozilla.com wrote: On 7/20/14 8:12 PM, David Henningsson wrote: From

[rust-dev] Rust and real-time audio

2014-10-07 Thread David Henningsson
Hi, I'm curious about the possibilities to use Rust for programming real-time audio stuff. Usually one has one small task that runs in high priority, and everything else is handled by a main task. I have a few questions related to this: 1) The real-time audio task should never block when

Re: [rust-dev] Rust and real-time audio

2014-10-08 Thread David Henningsson
as such? And then one could have a warning in case one uses such an item. On Wed, Oct 8, 2014 at 1:49 AM, David Henningsson di...@ubuntu.com mailto:di...@ubuntu.com wrote: Hi, I'm curious about the possibilities to use Rust for programming real-time audio stuff. Usually one has one

Re: [rust-dev] Rust and real-time audio

2014-10-13 Thread David Henningsson
On 2014-10-08 07:49, David Henningsson wrote: Hi, I'm curious about the possibilities to use Rust for programming real-time audio stuff. Usually one has one small task that runs in high priority, and everything else is handled by a main task. I have a few questions related to this: 1

Re: [rust-dev] Rust and real-time audio

2014-10-13 Thread David Henningsson
On 2014-10-08 07:49, David Henningsson wrote: Hi, I'm curious about the possibilities to use Rust for programming real-time audio stuff. Usually one has one small task that runs in high priority, and everything else is handled by a main task. I have a few questions related to this: 1

[rust-dev] Inheritance / delegation

2014-10-16 Thread David Henningsson
This is probably a previously asked question, but I couldn't find it on Google, so... Let's extend the Circle example from the guide a little: struct Circle { x:f64, y:f64, radius:f64, } trait HasArea { fn area(self)- f64; } impl HasArea for Circle { fn

Re: [rust-dev] Inheritance / delegation

2014-10-17 Thread David Henningsson
as_mut_circle(mut self) - mut Circle { mut self.circle } } The compiler will optimize trivial functions, except cross-crate. In those cases, use an #[inline] annotation. On Thu, Oct 16, 2014 at 10:57 PM, David Henningsson di...@ubuntu.com mailto:di...@ubuntu.com wrote: This is probably

Re: [rust-dev] Inheritance / delegation

2014-10-17 Thread David Henningsson
it in C. Regards, - Clark On Fri, Oct 17, 2014 at 4:27 AM, David Henningsson di...@ubuntu.com mailto:di...@ubuntu.com wrote: Hmm, right. The as_* could probably useful to write a macro for. Coming from the C/Java side of things I have to figure out how this works in a bigger

Re: [rust-dev] Inheritance / delegation

2014-10-17 Thread David Henningsson
it - in your enum example, you need to say Bag'a (for some defined 'a). For example, Bag'static means the pointed-to data lives as long as the program. On Fri, Oct 17, 2014 at 11:50 AM, David Henningsson di...@ubuntu.com mailto:di...@ubuntu.com wrote: Thanks for the answer. Deref is a new one

[rust-dev] Overhead of RcRefCellT

2014-10-20 Thread David Henningsson
Hi, So, I was trying to make a digraph where every node and edge has a property list (which can change during the lifetime of the node/edge), and I ended up with this structure: struct Edge { from_node: WeakRefCellNode, to_node: WeakRefCellNode, prop_list: HashMapString, String,

[rust-dev] Using an external crate from a module

2014-11-02 Thread David Henningsson
Hi, I'm wondering if external crate declarations from modules are discouraged in general? Because things seem to become a bit quirky, took me a while to grasp: First, use starts at the root whereas everything else starts at the current module. E g, imagine a test_seri.rs file which looks

Re: [rust-dev] Declaring the API unsafe while keeping the internal safety checks

2015-01-01 Thread David Henningsson
); } } -- Sincerely, Vladimir Farcaller Pouzanov http://farcaller.net/ ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev -- David Henningsson, Canonical Ltd. https://launchpad.net/~diwic

Re: [rust-dev] Declaring the API unsafe while keeping the internal safety checks

2015-01-02 Thread David Henningsson
); } } -- Sincerely, Vladimir Farcaller Pouzanov http://farcaller.net/ ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev -- David Henningsson, Canonical Ltd. https://launchpad.net/~diwic