Have we a pretty looks solution for auto incrementation counters during loops?
I mean something like C/C++ style for loop.I found an example in the manual
10.5 For loops but it looks ugly with counter outside the loop. Is it only
way for solving problem?
Thanks.
The int/uint::range methods would seem to do the job: for
uint::range(0, 10) |i| { io::println(fmt!(%u, i)); }
Cheers,
Josh
On 1 February 2013 12:14, Alexander Stavonin a.stavo...@gmail.com wrote:
Have we a pretty looks solution for auto incrementation counters during
loops? I mean something
Actually my first suggestion won't work except in trivial
circumstances (ie. starting from zero). Sorry.
On 1 February 2013 12:32, Josh Matthews j...@joshmatthews.net wrote:
Well, constant increments of N can be simulated with |let i = i * N;|
in the body of the loop. There's an issue open
Le 01/02/2013 13:28, Alexander Stavonin a écrit :
Thanks, it better than nothing, but… It works only for i++; how can I
write /i += 2 /or /i--/?
The range() function is very simple:
https://github.com/mozilla/rust/blob/release-0.5/src/libcore/int-template.rs#L48
#[inline(always)]
/// Iterate
It's also possible to write something like python's enumerate, to get:
for enumerate(some_vector) Ii, e| { ... }
In general, rust loops are closer to Python's and functional map than C++'s
looping constructs.
On 1 February 2013 12:37, Simon Sapin simon.sa...@exyr.org wrote:
Le 01/02/2013
I guess, the solution will not work for -1 … -10
On Feb 1, 2013, at 9:37 PM, Simon Sapin simon.sa...@exyr.org wrote:
Le 01/02/2013 13:28, Alexander Stavonin a écrit :
Thanks, it better than nothing, but… It works only for i++; how can I
write /i += 2 /or /i--/?
The range() function is very
Le 01/02/2013 13:38, Lucian Branescu a écrit :
It's also possible to write something like python's enumerate, to get:
for enumerate(some_vector) Ii, e| { ... }
In general, rust loops are closer to Python's and functional map than
C++'s looping constructs.
Python’s enumerate() works on any
There's already a function to do this:
fn main() {
for int::range_step(0, 10, 2) |i| {
log(error, i);
}
for int::range_step(10, 0, -1) |i| {
log(error, i);
}
}
On Fri, Feb 1, 2013 at 7:28 AM, Alexander Stavonin
Though note that this function is relatively new, you'll need to be on a
recent unstable version rather than 0.5.
On Fri, Feb 1, 2013 at 8:48 AM, Benjamin Striegel ben.strie...@gmail.comwrote:
There's already a function to do this:
fn main() {
for int::range_step(0, 10, 2) |i| {
What you want is something like this (and corresponding changes to the
impl):
pub trait TupleValT {
pub pure fn _1(self) - self/T;
pub pure fn _2(self) - self/T;
}
The `self` declaration is called an explicit self declaration. What
you have currently written is called implicit self
I'm having problems with the installer for 0.5 on Windows. I end up with
folders containing a mix of normal length files and zero length files.
When I try to run rustc.exe I get a dialog about some libgcc*.dll not
being present
Any clues?
Kind regards,
Bruce.
Am 30.01.2013 00:43, schrieb Brian Anderson:
On 01/29/2013 04:47 AM, Michael Neumann wrote:
Am 29.01.2013 03:01, schrieb Brian Anderson:
On 01/28/2013 05:29 PM, Graydon Hoare wrote:
On 13-01-28 04:56 PM, Brian Anderson wrote:
I think libuv is doing too much here. For example, if I don't
Le 01/02/2013 14:50, Benjamin Striegel a écrit :
Though note that this function is relatively new, you'll need to be on a
recent unstable version rather than 0.5.
Is it a bug that it’s not documented?
http://static.rust-lang.org/doc/core/int.html
--
Simon Sapin
On 13-02-01 06:39 AM, Bruce M. Axtens wrote:
I'm having problems with the installer for 0.5 on Windows. I end up with
folders containing a mix of normal length files and zero length files.
When I try to run rustc.exe I get a dialog about some libgcc*.dll not
being present
The 0-length files
On Fri, Feb 1, 2013 at 10:13 AM, Graydon Hoare gray...@mozilla.com wrote:
On 13-02-01 06:39 AM, Bruce M. Axtens wrote:
I'm having problems with the installer for 0.5 on Windows. I end up with
folders containing a mix of normal length files and zero length files.
When I try to run rustc.exe I
On Fri Feb 1 19:13:03 2013, Graydon Hoare wrote:
(they act as sequence-points for make, since it cannot easily guess
the actual hash-based output filenames of the libraries)
I was idly wondering about those hashy filenames: Is the long term plan
to continue to encoding hashes into the
strcat and I have been casually brainstorming about container traits.
Has there been previous discussion about standardizing a container trait
hierarchy and method naming convention?
Below is a rough sketch of a simple container framework, inspired by
Scala, Python, and C++ STL. Scala has a
On 13-02-01 10:21 AM, Felix S Klock II wrote:
On Fri Feb 1 19:13:03 2013, Graydon Hoare wrote:
(they act as sequence-points for make, since it cannot easily guess
the actual hash-based output filenames of the libraries)
I was idly wondering about those hashy filenames: Is the long term plan
On 13-02-01 10:36 AM, Chris Peterson wrote:
strcat and I have been casually brainstorming about container traits.
Has there been previous discussion about standardizing a container trait
hierarchy and method naming convention?
Not much; what we've had was encoded mostly in the core::iter and
FYI, I'm in the process of converting fun_treemap into an AA Tree and
implement much of the container traits. In the process, I've extracted out
the mutation functions from Map and Set into their own Mutable{Map,Set}
trait, and added Immutable{Map,Set} traits for persistent types. So
please talk
On 2/1/13 11:24 AM, Graydon Hoare wrote:
- I think the double-ended circular vec struct (implemented unsafely)
should probably be called Buf. It's the replacement for DVec.
Alternatively call it Queue and come up with another name for the
can access at either end trait. Deque
On 2/1/13 11:48 AM, Erick Tryzelaar wrote:
FYI, I'm in the process of converting fun_treemap into an AA Tree and
implement much of the container traits. In the process, I've extracted
out the mutation functions from Map and Set into their own
Mutable{Map,Set} trait, and added
On Friday, February 1, 2013, Chris Peterson wrote:
Is it necessary to differentiate Mutable- and Immutable- container traits
when mutating methods would take `mut self` and read-only accessors take
`self`?
Well, we need the MutableMap-style traits, but we could fold the
ImmutableMap-style
See also http://codemirror.net/mode/rust/ . Unfortunately, the syntax
has changed massively since I wrote that highlighting mode. On the
bright side, I believe the syntax became somewhat more regular, so
(though I'm not sure about this) a lot of the complexity in the
highlighter (and believe me,
Hi,
I am getting compilation error while implementing the nesting of modules as
per the Rust Language tutorial.
Below is the description of my code structure.
Inside example directory,I created a file orig.rs and declared 3 modules a,
b and c inside it. Inside module c, I declared another module
Is that the same syntax highlighter that github uses for their gists?
Pablo
On Fri, Feb 1, 2013 at 7:02 PM, Marijn Haverbeke mari...@gmail.com wrote:
See also http://codemirror.net/mode/rust/ . Unfortunately, the syntax
has changed massively since I wrote that highlighting mode. On the
On 02/01/2013 09:23 AM, Matthieu Monrocq wrote:
On Fri, Feb 1, 2013 at 12:09 PM, Michael Neumann mneum...@ntecs.de
mailto:mneum...@ntecs.de wrote:
Am 31.01.2013 23:37, schrieb Patrick Walton:
Hi everyone,
With the revamp of the scheduler underway, I'd like to propose
Thank you! But I still can not compile it:
1 pub trait TupleValT {
2 pub pure fn _1(self) - self/T;
3 pub pure fn _2(self) - self/T;
4 }
5
6 impl T(T, T): TupleValT {
7 pure fn _1(self) - self/T {
8 let (a, _) = self;
You need let (a, _) = *self or let (a, _) = self. self is a
pointer to a tuple, not a tuple.
Niko
Alexander Stavonin wrote:
Thank you! But I still can not compile it:
1 pub trait TupleValT {
2 pub pure fn _1(self) - self/T;
3 pub pure fn _2(self) - self/T;
4 }
5
Thank you very much! I guess had better extend your Borrowed pointers
tutorial with information about traits. At least for me it's unclear from the
tutorial.
On Feb 2, 2013, at 9:08 AM, Niko Matsakis n...@alum.mit.edu wrote:
You need let (a, _) = *self or let (a, _) = self. self is a pointer
I made changes as you told me:
1 pub trait TupleValT {
2 pub pure fn _1(self) - self/T;
3 /*pub pure fn _2(self) - self/T;*/
4 }
5
6 impl
Is that the same syntax highlighter that github uses for their gists?
No, Github uses Pygments for their syntax highlighting. And though there
exists a Rust highlighter in Pygments, it's a newer version of Pygments
that Github's Ruby-based Pygments wrapper doesn't yet support.
Though note that
Sorry, I told you wrong. When you write:
let (a, _) = self;
a
You are actually copying the value out of `self` and into the stack
variable `a`. The error message is telling you that you are returning a
pointer into your stack frame, which is of course unsafe.
What you actually want is
On 02/01/2013 03:14 PM, Brian Anderson wrote:
On 02/01/2013 09:23 AM, Matthieu Monrocq wrote:
On Fri, Feb 1, 2013 at 12:09 PM, Michael Neumann mneum...@ntecs.de
mailto:mneum...@ntecs.de wrote:
Am 31.01.2013 23:37, schrieb Patrick Walton:
Hi everyone,
With the revamp
On 02/01/2013 11:02 PM, Brian Anderson wrote:
On 02/01/2013 03:14 PM, Brian Anderson wrote:
On 02/01/2013 09:23 AM, Matthieu Monrocq wrote:
do reserve_stack(Standard) { rust_task_fail(); }
Of course that's
do reserve_stack(Standard) { unsafe { rust_task_fail(); } }
35 matches
Mail list logo