Re: [rust-dev] Overflow when benchmarking

2014-11-26 Thread Steven Fackler
The `nums` array is allocated on the stack and is 8 MB (assuming you're on a 64 bit platform). On Wed Nov 26 2014 at 8:23:08 PM Ben Wilson benwilson...@gmail.com wrote: Hey folks, I've started writing some rust code lately and run into weird behavior when benchmarking. When running

Re: [rust-dev] Why there's this asymmetry in defining a generic type/function/method and calling it?

2014-11-18 Thread Steven Fackler
The syntax is ambiguous: let foo = (HashMapFoo, Barnew()); is foo a HashMapFoo, Bar, or is it a tuple containing the results of these two comparisons: HashMap Foo and Bar new()? On Tue Nov 18 2014 at 1:38:26 PM Daniel Trstenjak daniel.trsten...@gmail.com wrote: Dear rust devs, is there

Re: [rust-dev] Rationale on if let

2014-10-14 Thread Steven Fackler
{ do_bar(); } ``` is equivalent to ``` loop { if !thing { break; } do_bar(); } ``` We judged that the convenience of the `if let` syntax justified its inclusion in the language, just like `for` and `while`. Steven Fackler On Tue, Oct 14, 2014 at 8:40 AM, Michael

Re: [rust-dev] Rationale on if let

2014-10-12 Thread Steven Fackler
`if let` acts on *any* refutable pattern, not just `Option`s. The RFC that proposed the syntax is a good place to look for the rationale of why it was added: https://github.com/rust-lang/rfcs/pull/160 Steven Fackler On Sun, Oct 12, 2014 at 10:41 PM, Michael Giagnocavo m...@giagnocavo.net wrote

Re: [rust-dev] Mutable files

2014-07-20 Thread Steven Fackler
{ a: int, b: 'static str }). In addition, if a type implements Drop, it is no longer Copy. Steven Fackler On Sun, Jul 20, 2014 at 7:39 PM, David Henningsson di...@ubuntu.com wrote: On 2014-07-21 03:33, Patrick Walton wrote: On 7/20/14 6:29 PM, David Henningsson wrote: Hi, Consider these two

Re: [rust-dev] Why no @Override analogy?

2014-07-16 Thread Steven Fackler
saying that if you *do* want to visit everything, you have to manually check to make sure you're overriding everything. Steven Fackler On Wed, Jul 16, 2014 at 11:59 AM, Christoph Husse thesaint1...@googlemail.com wrote: This comment from syntax::visit::Visitor really gives me a headache

Re: [rust-dev] no error or warning when an unknown attribute is used

2014-07-16 Thread Steven Fackler
given the compiler an opportunity to use it! Steven Fackler On Wed, Jul 16, 2014 at 5:16 PM, Ben Harris m...@bharr.is wrote: Have a quick skim over this ( http://tomlee.co/2014/04/03/a-more-detailed-tour-of-the-rust-compiler/). Lint is the last thing to run before conversion to LLVM. I'f you

Re: [rust-dev] Impending change in RPATH behavior when linking to Rust dynamic libraries

2014-07-09 Thread Steven Fackler
There's a fix for make install waiting on bors right now: https://github.com/rust-lang/rust/pull/15550 Steven Fackler On Wed, Jul 9, 2014 at 1:11 PM, Ben Gamari bgamari.f...@gmail.com wrote: Brian Anderson bander...@mozilla.com writes: Hi. Very soon now the way rustc links crates

Re: [rust-dev] Drop and lifetimes

2014-07-01 Thread Steven Fackler
to the Database instead. Steven Fackler On Tue, Jul 1, 2014 at 7:35 AM, David Brown dav...@davidb.org wrote: Imagine a hypothetical database interface: struct Database { ... } struct Cursor'a { db: 'a Database, ... } impl Database { fn query'a('a self

Re: [rust-dev] Error while trying to split source code into multiple files

2014-06-01 Thread Steven Fackler
/ mod.rs bar/ mod.rs The first configuration seems to be what most code uses. If bar ends up having submodules of its own, it would need to move to the second setup. Steven Fackler On Sun, Jun 1, 2014 at 3:02 PM, Nicholas Bishop nicholasbis...@gmail.com wrote

Re: [rust-dev] Error while trying to split source code into multiple files

2014-06-01 Thread Steven Fackler
Yep! main.rs: mod foo; mod bar; fn main() { foo::foo(); } foo.rs: use bar; // this use lets you refer to the bar fn as bar::bar() instead of ::bar::bar() pub fn foo() { bar::bar(); } bar.rs: pub fn bar() {} Steven Fackler On Sun, Jun 1, 2014 at 5:25 PM, Nicholas Bishop

Re: [rust-dev] Detection of early end for TakeIterator

2014-05-30 Thread Steven Fackler
It may not fulfill your exact use case, but you can get this in a way: let mut foo = bar.iter().peekable(); { let mut limit_foo = foo.by_ref().limit(50); for baz in limit_foo { ... } } if foo.is_empty() { ... } Steven Fackler On Fri, May 30, 2014 at 9:51 AM, Evan G eg1

Re: [rust-dev] Why explicit named lifetimes?

2014-05-15 Thread Steven Fackler
Type annotations are not there for the compiler; they're there for people reading the code. If I want to use some function I don't want to be forced to read the entire implementation to figure out what the lifetime of the return value is. Steven Fackler On Thu, May 15, 2014 at 9:30 PM, Tommi

Re: [rust-dev] Removal of sigils : ~T,~[T], BoxT, VecT

2014-05-04 Thread Steven Fackler
That will be possible, but the Index trait needs to be overhauled first. Steven Fackler On Sun, May 4, 2014 at 3:01 PM, Brian Rogoff brog...@gmail.com wrote: On Sat, May 3, 2014 at 2:27 AM, Artella Coding artella.cod...@googlemail.com wrote: Hi looking at https://github.com/rust-lang/rfcs

Re: [rust-dev] possible code dump bug (state machine iterator)

2014-04-18 Thread Steven Fackler
crashing. Adjusting the struct definition to struct StateMachineIter { statefn: fn(mut StateMachineIter) - Option'static str } should make things work as you want. There's also a bug in rustc for even letting that program compile. I'm not sure if it's already been run into and filed. Steven

Re: [rust-dev] Shouldn't task::try(...).unwrap() fail to compile?

2014-04-17 Thread Steven Fackler
You can use task::try(...).ok().unwrap() for Results with non-Show error types. Steven Fackler On Thu, Apr 17, 2014 at 8:55 AM, Edward Wang edward.yu.w...@gmail.comwrote: It current can compile, but judging from signatures: std::task::try is pub fn tryT: Send(f: proc(): Send - T) - ResultT

Re: [rust-dev] Is it possible to implement extension methods on existing traits?

2014-04-05 Thread Steven Fackler
You can do it like this: implT: Writer MySerialization for T { ... } Steven Fackler On Sat, Apr 5, 2014 at 12:57 PM, Frank Huang m...@nongraphical.com wrote: Hello everyone, I have a question about making extension methods on something like io::Writer. Basically, I have a data format

Re: [rust-dev] to ! or not to !

2014-03-14 Thread Steven Fackler
println is a function in std::io that prints strings to standard out. println! is a macro that allows for formatted output (e.g. println!(hello, {}!, world)). More details here: http://static.rust-lang.org/doc/master/std/fmt/index.html Steven Fackler On Fri, Mar 14, 2014 at 2:52 PM, Renato

Re: [rust-dev] let mut - var

2014-01-30 Thread Steven Fackler
The Zen of Python also says There should be one-- and preferably only one --obvious way to do it. Steven Fackler On Thu, Jan 30, 2014 at 11:35 AM, Donaldo Fastoso donquest...@rocketmail.com wrote: I like python's rational of consenting adults: Give people the tools to do the right thing

Re: [rust-dev] Deriving keyword

2014-01-23 Thread Steven Fackler
and it's unclear whether or not that's a good idea. Steven Fackler On Thu, Jan 23, 2014 at 8:32 PM, benjamin adamson adamson.benja...@gmail.com wrote: Question, what constitutes whether a 'trait' is applicable for implementation by the #deriving() attribute? According to the language

Re: [rust-dev] NewType change in 0.9

2014-01-11 Thread Steven Fackler
Something like this should work: pub fn cell_alive(self, Row(row): Row, Column(column): Column) - uint { return match self.inner[row][column].value { dead = 0, alive = 1 }; } Steven Fackler On Sat, Jan 11, 2014 at 2:03 PM, benjamin adamson adamson.benja...@gmail.com wrote

Re: [rust-dev] Announcing rust-openssl

2013-12-29 Thread Steven Fackler
There's an old open PR to optionally integrate with rust-ssl or rust-nss ( https://github.com/chris-morgan/rust-http/pull/31) but it'd need to be updated. Steven Fackler On Sun, Dec 29, 2013 at 10:12 AM, Patrick Walton pcwal...@mozilla.comwrote: On 12/29/13 7:48 AM, Erick Tryzelaar wrote

Re: [rust-dev] Interface around SQL databases

2013-12-11 Thread Steven Fackler
just to push the APIs of different SQL client libraries closer together. Someone could absolutely take the interface used by rust-postgres and make a MySQL/MariaDB driver with it, but that person wouldn't be me :) Steven Fackler On Wed, Dec 11, 2013 at 7:15 AM, Gaetan gae...@xeberon.net wrote: I

Re: [rust-dev] Please simplify the syntax for Great Justice

2013-11-11 Thread Steven Fackler
encoded data into a URL you're going to have to use URL_SAFE instead of STANDARD. If you're trying to send an email, you'll need to use MIME instead of STANDARD. If you're talking to a service that requires one of the ~10 other variants of Base64, you'll need to use a custom config struct. Steven Fackler

Re: [rust-dev] Strange behavior about Writer trait

2013-10-19 Thread Steven Fackler
If T is a trait, its trait objects ~T, @T and T do not implement T. There is an implementation of Writer for @Writer, but not for ~Writer or Writer which is why you're seeing that error. Steven Fackler On Fri, Oct 18, 2013 at 11:27 PM, Oren Ben-Kiki o...@ben-kiki.org wrote: Ugh, I was too

Re: [rust-dev] Should I/O use conditions?

2013-10-16 Thread Steven Fackler
it into a new ~str. In the IO case, you could keep this cost free to implement by having `Reader` contain a default implementation for `read` and only require users to implement `try_read`. See http://docs.octayn.net/postgres/struct.PostgresConnection.html for some examples. Steven Fackler

Re: [rust-dev] Trait method self parameter type clashes with lifetime annotation required by the implementation

2013-09-29 Thread Steven Fackler
if we replace self.bar or self.bar.baz. Steven Fackler On Sun, Sep 29, 2013 at 3:15 PM, Tim Kuehn tku...@cmu.edu wrote: Could you use struct methods for quick access? Or is there a reason this wouldn't fit your use case? Sorry, I haven't followed the whole thread closely. struct Owner