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 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 that fails
On Sat, Feb 8, 2014 at 6:48 PM, Ashish Myles wrote:
>
> On Sat, Feb 8, 2014 at 1:21 PM, Philippe Delrieu > wrote:
>
>> pub trait Base {
>> fn do_base(&self);
>> }
>>
>> struct TestBase;
>>
>> impl Base for TestBase
On Sat, Feb 8, 2014 at 1:21 PM, Philippe Delrieu
wrote:
> pub trait Base {
> fn do_base(&self);
> }
>
> struct TestBase;
>
> impl Base for TestBase{
> fn do_base(&self){
> println!("ici");
> }
> }
>
> trait GenerciFn{
> fn do_generic(&self, base: &T);
> }
>
> st
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 wrote:
>
add others). Not ideal, but useful until this
> gets straightened out.
>
>
>
>
>
> On Sun, Jan 19, 2014 at 12:19 AM, Daniel Micay wrote:
>
>> On Sun, Jan 19, 2014 at 12:17 AM, Ashish Myles
>> wrote:
>> > Now, I already know that statically-sized arrays of
Thanks for the detailed explanations!
On Sun, Jan 19, 2014 at 2:01 AM, Alex Crichton wrote:
> > fn borrow1<'a>(&'a self) -> &'a int {
> > match (self) {
> > // error: mismatched types: expected `&'a int` but found
> `~int`
> > // (expected &-ptr but found ~-pt
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 treate
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
d
tln!("{:?}", b);
> }
> );
> )
>
> Multi-statement 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
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
#
gt; let foo = Foo([1.0, 2.0, 3.0]);
> println!("{:?}", foo[tmp]);
> }
>
> On 9 Jan 2014, at 2:08 pm, Ashish Myles wrote:
>
> > The following implementation of Index for Foo works fine.
> >
> > struct Foo([f64, ..3]);
> > impl Index for Foo {
The following implementation of Index for Foo works fine.
struct Foo([f64, ..3]);
impl Index 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, 2.0, 3.0
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
(i));
> }
> }
> ary
> }
>
>
> This would let you call it like Foo(array::from_fn(|_| Zero::zero())).
>
> -Kevin
>
> On Nov 29, 2013, at 8:37 PM, Ashish Myles wrote:
>
>> That's some seriously nifty stuff, which got my stuff compiling again.
ntrinsics::uninit();
> for i 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 wr
?
On Nov 29, 2013 6:47 PM, "Huon Wilson" 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
&g
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
DeepClone,
On Sat, Jul 6, 2013 at 10:26 PM, Daniel Micay wrote:
> On Sat, Jul 6, 2013 at 10:09 PM, Ashish Myles wrote:
>> 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 de
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]
impl ToStr for ~[A]
impl ToStr for @[A]
whereas only the first
On Sat, Jul 6, 2013 at 5:45 AM, Jason Fager 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 cool:
st
On Sat, Jul 6, 2013 at 1:43 AM, Patrick Walton 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
&g
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 to be able to write, for example,
[Zero::zero(),.. 3] as in the fo
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 inte
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| {
On Wed, Jul 3, 2013 at 4:00 PM, Ashish Myles 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
(0c6fc46c030ab0515a052fa99c9e10c75c
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
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 wrote:
> On 23/06/13 12:53, Ashish Myles wrote:
>>
>&
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 |&
> - 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
Ha! I asked the same question when I first started. I wouldn't be
surprised if this is a common cause of confusion for people coming
from C++ and that name resolution family.
Perhaps notes regarding this could be added to
https://github.com/mozilla/rust/wiki/Rust-for-CXX-programmers
?
Ashish
On
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);
}
On Sat, Mar 2, 2013 at 2:20 PM, Ashish Myles wrote:
> On Sat, Mar 2, 2013 at 1:41 PM, Paul Stansifer
> 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://
On Sat, Mar 2, 2013 at 1:41 PM, Paul Stansifer 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 workaround. Perhaps it shoul
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));
// P
On Sun, Feb 24, 2013 at 3:03 PM, Ashish Myles wrote:
>
> Wait a sec...I guess we are barking up the wrong tree. The problem is
> not that rust macros don't support $n:integer, but that static array
> initialization seem to require a raw integer literal (possibly at the
> pars
On Sun, Feb 24, 2013 at 12:06 AM, Ashish Myles wrote:
> On Fri, Feb 22, 2013 at 12:35 PM, John Clements
> 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
>
On Fri, Feb 22, 2013 at 12:35 PM, John Clements
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
> > information that it is a nu
Thanks for all the corrections and feedback so far. Another strange one
that has me stumped. This one gives me a strange error that reads like the
e-mail subject.
macro_rules! VectorT {
($Vec:ident, $n:expr) => (
struct $Vec {
priv mut m_v: [T * $n];
}
);
}
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 Vector3 {
priv mu
Thanks for all the answers.
On Thu, Feb 21, 2013 at 9:17 AM, Niko Matsakis wrote:
>
>
> Ashish Myles wrote:
>
>> Lots of questions.
>>
>> 1. Is there an array string join function? I looked through possible
>> pertinent vector- and string-related modul
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? i.e.
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 List {
Nil,
Cons(T, @List)
}
If one wished to move such a list to another task, a copy to unique
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
44 matches
Mail list logo