[rust-dev] Issue in borrowing

2013-08-21 Thread Piyush Agarwal
Title: Samsung Enterprise Portal mySingle


Hi All,
Rust Compiler is giving error in following code :-

fn main() {
let mut vec = ~[1 ,2 , 3, 4];f1(mut vec);
}
fn f1 (b: mut ~[int]) {
let mut a = mut b[0];//process(a);a = mut b[3];}

error: cannot borrow '(**b)[]' as mutable more than once at a time

Thanks and Regards,
Piyush Agarwal





___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


[rust-dev] task failed at borrowed

2013-06-25 Thread piyush agarwal
Hi all,

When I run this code

fn main() {
let mut x = @mut 2;
let y = x;
{
let z =  *y;
x = @mut 3;
io::println(fmt!(%? , y));
*y = 5;
io::println(fmt!(%? , y));
}
}


following occurs.

rust: task failed at 'borrowed', ???:0
rust: domain main @0xef89c0 root task failed

can anyone explain? (using compiler 0.6 )


-- 
Piyush Agarwal
Please don’t print this e-mail unless you really need to!
___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


[rust-dev] Problem Understanding compiler errors

2013-04-03 Thread piyush agarwal
Hi all,

This code used to work in 0.5 version but wehn i updated my compiler to
prerelease of 0.6 , these errors occurs which I am not able to understand.


#[link(name = testVector, vers = 1.0)];
#[crate_type = lib];
extern mod std;

pub struct test {
testStruct: @mut([~[int], ..4])
}

impl test {
pub fn print_lenght(mut self) {
io::println(uint::to_str(self.testStruct[2].len()));
}
}

fn test() - @mut test{
@mut test {
testStruct: @mut([~[], ..4])
}
}


testVector.rs:12:27: 12:44 error: illegal borrow unless pure: unique value
in aliasable, mutable location
testVector.rs:12 io::println(uint::to_str(self.testStruct[2].len()));
   ^
testVector.rs:12:27: 12:52 note: impure due to access to impure function
testVector.rs:12 io::println(uint::to_str(self.testStruct[2].len()));
___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


[rust-dev] Error creating vector of vectors

2013-04-02 Thread piyush agarwal
Hi all,

I am finding errors while creating vector of vectors after updating my
compiler to pre-release version of rust-0.6.


let mut testStruct: @[~[int], ..4] = @[~[], ..4];

or

let mut testStruct: ~[~[int], ..4] = ~[~[], ..4];


Thanks,
Piyush
___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


[rust-dev] Query Related to enum

2013-03-05 Thread piyush agarwal
Hi,

I have a enum for example

enum A{
a = 0,
b = 1,
c = 2 }



what I want is :-
when I pass '2' , I can get c from it.

Is there some built-in for this or some other way.


Thanks,

Piyush
___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


[rust-dev] Hash Table

2013-01-31 Thread piyush agarwal
How can we implement hash table in rust ..or there is any built-in type for
it.

-- 
Piyush Agarwal
Please don’t print this e-mail unless you really need to!
___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev