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 wrote: > Hey folks, I've started writing some rust code lately and run into weird > behavior when benchmarking. When running > > https://gist.github.com/benw

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 = (HashMapnew()); is foo a HashMap, 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 a reason

Re: [rust-dev] surprising test failure with "panicked at 'Box'"

2014-11-17 Thread Steven Fackler
assert! Takes a boolean expression and an optional error message. The `false` is being interpreted as an error message which results in the Box output. You probably want to use assert_eq! On Mon Nov 17 2014 at 8:31:46 AM Max R.D. Parmer wrote: > The code and error generated from the test suite a

Re: [rust-dev] Rationale on if let

2014-10-14 Thread Steven Fackler
thing { 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, M

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 wrote: > I came acr

Re: [rust-dev] file logger missing?

2014-07-22 Thread Steven Fackler
Is a logger that synchronously writes to the filesystem and doesn't offer any type of rotation more useful than redirecting stderr? Steven Fackler On Tue, Jul 22, 2014 at 8:11 AM, Diggory Hardy wrote: > Are you saying that liblog should be moved too? Because I don't see wh

Re: [rust-dev] Mutable files

2014-07-20 Thread Steven Fackler
Foo { 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 wrote: > > > On 2014-07-21 03:33, Patrick Walton wrote: > >> On 7/20/14 6:29 PM, David Henningsson wrote

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

2014-07-16 Thread Steven Fackler
ntil we've given the compiler an opportunity to use it! Steven Fackler On Wed, Jul 16, 2014 at 5:16 PM, Ben Harris 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 L

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

2014-07-16 Thread Steven Fackler
omment is just 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::Vi

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 wrote: > Brian Anderson writes: > > > Hi. > > > > Very soon now the way rustc links crates dynamic

Re: [rust-dev] Drop and lifetimes

2014-07-01 Thread Steven Fackler
tains a reference to the Database instead. Steven Fackler On Tue, Jul 1, 2014 at 7:35 AM, David Brown wrote: > Imagine a hypothetical database interface: > >struct Database { ... } >struct Cursor<'a> { >db: &'a Database, >... >

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 wrote

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

2014-06-01 Thread Steven Fackler
foo/ 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 wrote: > Here's

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

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

Re: [rust-dev] Glob crate?

2014-05-26 Thread Steven Fackler
A glob crate like this one? https://github.com/mozilla/rust/blob/master/src/libglob/lib.rs Steven Fackler On Mon, May 26, 2014 at 6:57 PM, Daniel Fagnan wrote: > Writing it here to gauge an interest of the community for a glob crate. If > it seems people are liking the idea, I'll w

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

Re: [rust-dev] Removal of sigils : ~T,~[T], Box, Vec

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 wrote: > On Sat, May 3, 2014 at 2:27 AM, Artella Coding < > artella.cod...@googlemail.com> wrote: > >> Hi looking at https://github.com/r

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

2014-04-18 Thread Steven Fackler
that program compile. I'm not sure if it's already been run into and filed. Steven Fackler On Fri, Apr 18, 2014 at 8:30 AM, Ziad Hatahet wrote: > Confirm repro on an older rustc version. Ubuntu 13.10 running rustc > 0.11-pre (ecc774f 2014-04-11 13:46:45 -0700). > > >

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 wrote: > It current can compile, but judging from signatures: > > std::task::try is pub fn try(f: proc(): Send -> T) -> Result ~Any:Send

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: impl MySerialization for T { ... } Steven Fackler On Sat, Apr 5, 2014 at 12:57 PM, Frank Huang wrote: > Hello everyone, > > I have a question about making "extension methods" on something like > io::Writer. Basically, I have a data format th

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, 201

Re: [rust-dev] Handling I/O errors

2014-02-03 Thread Steven Fackler
You can also use a nested pattern: match reader.read(buf) { Ok(cnt) => { /* stuff */ } Err(IoError { kind: EndOfFile, .. } => { /* eof stuff */ } Err(e) => return Err(e) } Steven Fackler On Mon, Feb 3, 2014 at 10:32 PM, Alex Crichton wrote: > I'd recommend one

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

Re: [rust-dev] Compile-time function evaluation in Rust

2014-01-29 Thread Steven Fackler
which is currently only used with `extern mod` statements but could be extended to functions and whatever else: #[phase(syntax)] fn ctfe_function() -> int { 10 } static FOO: int = ctfe_function(); Steven Fackler On Wed, Jan 29, 2014 at 11:44 AM, Niko Matsakis wrote: > On Tue, Jan 28

Re: [rust-dev] Deriving keyword

2014-01-23 Thread Steven Fackler
syntax extensions aren't 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 > implementati

Re: [rust-dev] Exporting macros: #[macro_escape] usage

2014-01-20 Thread Steven Fackler
#[macro_export] exports macros from one crate to another (across an "extern mod" boundary). It doesn't have any effect inside of the crate in which it is defined. Steven Fackler On Sun, Jan 19, 2014 at 11:50 PM, Vladimir Matveev wrote: > I thought so :) > By the way, is

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...@

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 wrote: > On 12/29/13 7:48 AM, Erick Tryzelaar wrote: > &

Re: [rust-dev] Interface around SQL databases

2013-12-11 Thread Steven Fackler
ic API would be nice 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

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

2013-11-11 Thread Steven Fackler
ts of Base64, you'll need to use a custom config struct. Steven Fackler On Mon, Nov 11, 2013 at 5:23 PM, Brendan Zabarauskas wrote: > On 12 Nov 2013, at 10:12 am, John Clements > wrote: > > > If you had the energy to build an alternate front-end using a > parenthesized syntax,

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

2013-10-18 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 wrote: > Ugh, I was too

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

2013-10-16 Thread Steven Fackler
py 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 O

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

2013-09-29 Thread Steven Fackler
oo.baz would point to deallocated memory if we replace self.bar or self.bar.baz. Steven Fackler On Sun, Sep 29, 2013 at 3:15 PM, Tim Kuehn wrote: > Could you use struct methods for "quick access"? Or is there a reason this > wouldn't fit your use case? Sorry, I haven&#