And just in case there is a confusion (as I have noticed others to
have), it might help to see a specific example comparing static
dispatch with dynamic.
// This is a single function for all types implementing the LCD Trait.
fn foo(x : LCD) { // x's type is LCD rather than the actual type of
the
On Tue, Feb 25, 2014 at 11:00 AM, Phil Dawes rustp...@phildawes.net wrote:
fn main() {
let arr : ~[str] = std::os::args()[1].split_str(::).collect();
std::io::println(first + arr[0]);
std::io::println(first again + arr[0]);
}
I am working on an older version of the compiler
On Sat, Feb 8, 2014 at 6:48 PM, Ashish Myles marci...@gmail.com wrote:
On Sat, Feb 8, 2014 at 1:21 PM, Philippe Delrieu philippe.delr...@free.fr
wrote:
pub trait Base {
fn do_base(self);
}
struct TestBase;
impl Base for TestBase{
fn do_base(self){
println
Thanks for the detailed explanations!
On Sun, Jan 19, 2014 at 2:01 AM, Alex Crichton a...@crichton.co wrote:
fn borrow1'a('a self) - 'a int {
match (self) {
// error: mismatched types: expected `'a int` but found
`~int`
// (expected -ptr but found
straightened out.
On Sun, Jan 19, 2014 at 12:19 AM, Daniel Micay danielmi...@gmail.comwrote:
On Sun, Jan 19, 2014 at 12:17 AM, Ashish Myles marci...@gmail.com
wrote:
Now, I already know that statically-sized arrays of primitives are
implicitly copyable, but consider, for example, a statically
Thanks! I appreciate the detailed answers and look forward to future
changes. :)
And I had already run into and started reading Niko's article you linked
for DSTs.
I love the thorough analyses you guys go through for each feature.
Ashish
On Sun, Jan 19, 2014 at 1:17 PM, Alex Crichton
I understand as per a previous discussion that the owned box ~[T] doesn't
quite have the semantics of a unique *pointer*. Below include my successes
in some borrowing scenarios and analogous failed attempts at borrowing a
reference to a unique pointer to an array within a FooVec struct. How do I
Now, I already know that statically-sized arrays of primitives are
implicitly copyable, but consider, for example, a statically-sized array of
a non-copyable but Clone-able type. I find that for v of type [T, ..2],
v.clone() is not a static array. Perhaps it's because v is being
implicitly
Rust 0.9 indicates that support for expansion of macros into multiple
statements is now supported, and the following example from the test suite
works for me.
https://github.com/mozilla/rust/blob/master/src/test/run-pass/macro-multiple-items.rs
However, I receive an error for the following code
macros are covered by
https://github.com/mozilla/rust/issues/10681 .
Huon
On 12/01/14 13:40, Ashish Myles wrote:
Rust 0.9 indicates that support for expansion of macros into multiple
statements is now supported, and the following example from the test suite
works for me.
https
The following implementation of Index for Foo works fine.
struct Foo([f64, ..3]);
impl Indexuint, f64 for Foo {
fn index(self, index: uint) - f64 {
match self {
Foo(ref v) = v[*index].clone()
}
}
}
fn main() {
let tmp : uint = 0;
let foo = Foo([1.0,
!({:?}, foo[tmp]);
}
On 9 Jan 2014, at 2:08 pm, Ashish Myles marci...@gmail.com wrote:
The following implementation of Index for Foo works fine.
struct Foo([f64, ..3]);
impl Indexuint, f64 for Foo {
fn index(self, index: uint) - f64 {
match self {
Foo(ref v) = v
I think I see the confusion (as I suffered from the same point of
confusion). So let me restate your answer and please correct me of I am
wrong.
1. mut int and mut int are different types and the former doesn't
automatically convert to the latter.
2. The way to get the latter from the former is
Previously we had the Copy trait, which when implemented by trait T
allowed one to write
[Zero::zero(), ..SZ] where T implemented the Zero trait. But now I am
not sure how to get that behavior. Concretely, here is the code I
want to get compiling. (Just to check, I added both Clone and
?
On Nov 29, 2013 6:47 PM, Huon Wilson dbau...@gmail.com wrote:
On 30/11/13 10:33, Ashish Myles wrote:
Previously we had the Copy trait, which when implemented by trait T
allowed one to write
[Zero::zero(), ..SZ] where T implemented the Zero trait. But now I am
not sure how to get
in range(0u, SZ as uint) {
intrinsics::move_val_init(mut ary[i], Zero::zero());
}
}
Foo(ary)
}
}
-Kevin
On Nov 29, 2013, at 7:05 PM, Ashish Myles marci...@gmail.com wrote:
Is there a plan to support fix-sized vector initialization without
On Nov 29, 2013, at 8:37 PM, Ashish Myles marci...@gmail.com wrote:
That's some seriously nifty stuff, which got my stuff compiling again. :)
But for the long term, it would be nice to have a syntax that behaves
as was the case with the Copy trait -- it takes a single value and
clones
On Sat, Jul 6, 2013 at 1:43 AM, Patrick Walton pwal...@mozilla.com wrote:
On 7/5/13 10:42 PM, Ashish Myles wrote:
And an additional question.
3. What is the rationale in having both Copy and Clone? Can one
provide an exhaustive list for where one would want to use Copy
instead of Clone
On Sat, Jul 6, 2013 at 5:45 AM, Jason Fager jfa...@gmail.com wrote:
I've started implementing traits for fixed-length vectors with a few macros:
https://gist.github.com/jfager/5936197
I don't have Clone yet, but it should be easy to add.
As a side note, looking through your code, this is
Perhaps this was an oversight as the code base has developed
organically. But in case it was intentional, I just wanted to check.
libstd/to_str.rs defines each of the following impls
impl'self,A:ToStr ToStr for 'self [A]
implA:ToStr ToStr for ~[A]
implA:ToStr ToStr for @[A]
whereas
1. The following code
#[deriving(Clone)]
struct V {
v : [f64, ..3]
}
fn main() {
}
gives the following error
tmp.rs:1:11: 1:16 error: mismatched types: expected `[f64, .. 3]` but found
`[f64, .. 3]` (expected vector but found -ptr)
tmp.rs:1 #[deriving(Clone)]
Is this
And an additional question.
3. What is the rationale in having both Copy and Clone? Can one
provide an exhaustive list for where one would want to use Copy
instead of Clone/DeepClone? I tried to use clone everywhere, but I
needed T : Copy + Zero to be able to write, for example,
[Zero::zero(),..
openSUSE 12.2 (i.e. previous release). make check succeeds:
summary of 25 test runs: 5261 passed; 0 failed; 302 ignored
___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev
On Wed, Jul 3, 2013 at 4:00 PM, Ashish Myles marci...@gmail.com wrote:
openSUSE 12.2 (i.e. previous release). make check succeeds:
summary of 25 test runs: 5261 passed; 0 failed; 302 ignored
To clarify, I did the check against trunk
(0c6fc46c030ab0515a052fa99c9e10c75cfc8184), and my
Any idea why the following fails
use std::{io,rand,task};
fn main() {
for [Alice, Bob, Carol].iter().advance |name| {
do task::spawn {
use std::rand::RngUtil;
let v = rand::rng().shuffle([1, 2, 3]);
for v.iter().advance |num| {
Great, thanks, it works!
Is there a way to invoke the shuffle() without bringing it explicitly
into local scope, say via some verbose way that specifies the trait to
be used?
Ashish
On Sat, Jun 22, 2013 at 11:00 PM, Huon Wilson dbau...@gmail.com wrote:
On 23/06/13 12:53, Ashish Myles wrote
- tjc's pre-talk and talk, Rust: A Friendly Introduction went very well. The
[slides](http://catamorphism.org/Writing/Rust-Tutorial-tjc.pdf) are up, and
a recording is coming soon (hopefuly). tjc says the slides aren't as
understanable without the audio of the talk.
Thanks for the
I have been out of rust for a bit, and coming back to it, I am having
a difficult time adapting the front page example at
http://www.rust-lang.org/ to the trunk version of rust (updated last
night). I turned the example to
use std::*;
fn main() {
for [Alice, Bob, Carol].each |name|
Hi,
I am running the rust compiler from trunk. My macro usage seems to be a
macro_rules! my_print(
($a:expr, $b:expr) = (
io::println(fmt!(%d, a));
io::println(fmt!(%d, b));
);
)
fn main() {
let a : int = 1;
let b : int = 2;
my_print!(a, b);
}
So far, I have had a difficult time finding anything definitive on this
except for some rust test code.
fn main() {
// PART 1: works (from rust test code)
let asdf_fdsa = ~.;
io::println(concat_idents!(asd, f_f, dsa));
io::println(stringify!(use_mention_distinction));
// PART
On Sat, Mar 2, 2013 at 1:41 PM, Paul Stansifer paul.stansi...@gmail.com wrote:
`concat_idents!` is currently broken, and it's my fault. Here's a
discussion of how it might be fixed in the future:
https://mail.mozilla.org/pipermail/rust-dev/2013-February/003170.html Sadly,
there is no
On Sun, Feb 24, 2013 at 12:06 AM, Ashish Myles marci...@gmail.com wrote:
On Fri, Feb 22, 2013 at 12:35 PM, John Clements
cleme...@brinckerhoff.org wrote:
On Feb 22, 2013, at 6:22 AM, Paul Stansifer wrote:
Rust syntax expects a literal number in the `[T * n]` construct; from the
parser's
On Fri, Feb 22, 2013 at 12:35 PM, John Clements
cleme...@brinckerhoff.org wrote:
On Feb 22, 2013, at 6:22 AM, Paul Stansifer wrote:
Rust syntax expects a literal number in the `[T * n]` construct; from the
parser's point of view, what it receives is an expression, without any
Well, I eventually figured out how to get things compiling, but it was
highly non-obvious. I would appreciate it if someone could shed some light
on why things behave this way so that I may learn to visually see the
error.
Say we have the following struct
pub struct Vector3T {
priv
I didn't much previous discussion on this topic on google. Sorry if I
missed something and re-starting an old discussion.
Here is an example from the manual of a standard lisp-style list.
enum ListT {
Nil,
Cons(T, @ListT)
}
If one wished to move such a list to another task, a copy to
Lots of questions.
1. Is there an array string join function? I looked through possible
pertinent vector- and string-related modules and I didn't see
something equivalent.
2. Any particular reason to_str() for arrays (defined in in std::to_str)
is defined only for unique arrays?
Firstly, as this seems to be the only discussion mailing list for rust, I
presumed that this might be a good place to ask newbie-ish questions.
Please correct me if I am wrong. (I have previously played around with D,
which has separate mailing lists for learners.)
I am particularly interested in
37 matches
Mail list logo