Hi, Daniel,
Consider this example:
let vec = vec![(1u, 2u)];
for (a, b) in vec.iter() {
println!({}: {}, a, b);
}
a and b here are of type uint, which is implicitly copyable. It is not
natural to take references to it when passing around its values. That
is, variables under
Hi, Ollie,
This variant is terser, but it could be even more readable if there were some
kind of connect() for iterators. It surprised me that there is no such thing in
Rust iterators. It would be possible to use some kind of interleave() for
iterators for the same purpose, but there is no
Hi, Allen!
In fact, it is possible to do it now without DST, using unboxed closures only:
#![feature(unboxed_closures, unboxed_closure_sugar)]
fn make_adder(x: int) - Box|: int| - int {
box |: y: int| x + y
}
fn main() {
let f = make_adder(3);
println!({}, f.call((4i,)));
}
Test
Hi!
These libraries may be interesting for you:
* https://github.com/servo/rust-png
* https://github.com/PistonDevelopers/rust-image
It is also very simple to run external tools like ImageMagick from Rust. You
will need Command [1] API for that.
[1]:
On Monday 8 September 2014 at 15:57, Vladimir Matveev wrote:
Hi!
These libraries may be interesting for you:
* https://github.com/servo/rust-png
* https://github.com/PistonDevelopers/rust-image
It is also very simple to run external tools like ImageMagick from Rust. You
will need Command [1
Hi!
I’ve noticed this piece of code in your library:
#[inline]
fn as_mut_slice(self) - mut [u8] {
unsafe {
match self {
OwnedBuffer(ref v) = {
let mut_v: mut Vecu8 = mem::transmute(v);
mut_v.as_mut_slice()
},
Forgot to send a copy to mailing list.
2014-08-04 10:30 GMT+04:00 Vladimir Matveev dpx.infin...@gmail.com:
Hi, Paul,
The problem with Clone implementation for mutable reference is not
that it does not make sense at all; after all, it is just an integer
value behind the fancy name
Hi, Adrian,
Currently Rust uses static linking to build executables. This means that the
simplest «hello world» program utilizing standard library will take all of this
library and all dependent libraries, including Rust runtime, into itself.
That’s why the binary is large.
If you want to use
Hi, Isak!
According to manifest documentation [1] you can specify crate type (dynamic or
static lib or rlib) using crate_type option:
[[lib]]
…
crate_type = [dylib, staticlib]
The above configuration should build you both .a and .so files.
[1]: http://crates.io/manifest.html, search for
Overloading Mul for matrix multiplication would be a mistake, since that
operator does not act the same way multiplication acts for scalars.
I think that one of the main reasons for overloading operators is not their
genericity but their usage in the code.
let a = Matrix::new(…);
let
Hi, Kevin!
* What would be the replacement for a struct-scoped static constant, so I
could put a static inside a struct instead of making it a global?
It is not possible now. There are some suggestions on associated items, but I
don’t think they are active. Currently Rust module system is
Well, JSR-310 is implemented here [1], and it is licensed under GPL2 license.
As far as I remember, in that case Google reproduced some internal Java API, so
this seems to be a different thing. BTW, one of the implementors of JSR-310
suggested [3] looking into an older implementation which is
There is also rustsqlite[1].
It would be great to have generic bindings for databases, like in Go or in
Java. In Rust, however, reflective approaches of these won’t work because Rust
lacks structural reflection. I guess, generic bindings will have to follow type
classes approach, like
Hi, Fredrik,
Currently a new package manager designed specifically for Rust is under active
development. It is called Cargo, and you can find it here [1]. It is pretty
much in very alpha stage now, but one day it will become a full package manager
and build system for Rust.
[1]:
Aw, Gmail makes it so easy to press Reply instead of Reply to all.
See below :)
Hi, Christophe,
Because `Vec` looks like this:
struct VecT {
len: uint,
cap: uint,
data: *mut T
}
its actual size is just three words, so you can freely pass it around
regardless of number of
Hi, Christophe,
You shouldn't be using `~str` at all, you should use `String`. Also,
`box ` is not a replacement for `~`, they have different types.
The proper replacement is `String::new()` or `.to_string().
Your code in modern Rust will look like this:
/// Contains a list of properties. A
2014-05-30 5:37 GMT+04:00 Kevin Ballard ke...@sb.org:
It shouldn't.
The for-loop desugaring looks like
match mut st.execute_query() {
__i = loop {
match __i.next() {
None = break,
Some(mut __value) = {
let i = __value;
It happens even for this:
struct Test {
a: int
}
impl ToStr for Test {
fn to_str(self) - String {
self.a.to_str()
}
}
As you can see, Test is not implementing Show, so I assumed that I
could implement ToStr instead. I suspect that there is somewhere an
implementation
Hi, Christophe,
Won't wrapping the first `for` loop into curly braces help? I suspect
this happens because of `for` loop desugaring, which kind of leaves
the iterator created by `execute_query()` in scope (not really, but
only for borrow checker).
2014-05-29 19:38 GMT+04:00 Christophe Pedretti
regexp on it).
Urban
On Mon, May 26, 2014 at 8:58 AM, Vladimir Matveev dpx.infin...@gmail.com
wrote:
My suspicion is that the automatic conversion will come back at some
point, but I'm not sure.
I think it will be possible to make `String` implement `Derefstr`
when DST land
Hi!
First of all, if you are writing custom bindings to sqlite not only to
learn Rust, I'd suggest using already existing bindings [1]. That way
you probably won't have to deal with low-level C integration stuff.
However, if you want to learn how to write C bindings, you should
probably start
Christophe,
Indeed, the idiomatic way is to use Result enum [1]. Note that you are
not limited to IoResult, you can use any custom error type, for
example, ResultT, 'static str. The documentation (a link to which
is below) is very nice, it contains a lot of examples and use
patterns.
So, your
Hi all,
I posted this question on [Stack Overflow][1], but it is yet to be
answered there, so I ask here too.
Why reference to traits are not cloneable? The following code compiles:
struct Test;
fn clone_vec'a(v: Vec'a Test) - Vec'a Test {
v.clone()
}
But this one doesn't:
trait Test {
Hi, Tobias,
Yes, there is. A monad is a functor by definition, so it has to accept
a type to produce another type. It can't be represented in another
way, at least in Haskell. You can't come up with a sensible definition
of a functor without HKT:
class Functor (f :: *) probably something else
2014-02-02 Thomas Leonard tal...@gmail.com:
[ I don't want to start another argument, but since you guys are discussing
0install, maybe I can provide some useful input... ]
I don't follow this. Whether the developer uses 0install to get the build
dependencies doesn't make any difference to
Is it possible at all to find the latest version of a library which is
still compatible completely automatically? Incompatibilites can be
present on logic level, so the compilation wiith incompatible version
will succeed, but the program will work incorrectly. I don't think
that this can be solved
You can do that within a major version, except for one case - multiple
developers creating diverged versions of 2.13, based on 2.12, each with
their own features.
...
But doing it per major version recursively raises the question of which
major version is authorised: what if you have a
To clarify, when I was writing user I meant the developer who uses this
package, not the end user of complete program.
On 01/02/14 19:32, Vladimir Matveev wrote:
When this API is used directly by the package, then the user *should*
know about it. He's using it, after all
{
let Test1 { a, b } = self;
Test2 {
c: a,
d: b as f64
}
}
On Sun, Jan 26, 2014 at 9:32 AM, Vladimir Matveev
dpx.infin...@gmail.com wrote:
Hi all,
Consider this code:
struct Test1 {
a: ~str,
b: f32,
}
struct Test2
() be sufficient? Or is it because of the lifetimes?
On Jan 20, 2014 1:41 AM, Vladimir Matveev dpx.infin...@gmail.com wrote:
Hi,
In fact, you're almost there. You only need to add lifetime
annotations on `Sprite` in the intermediate HashMap variable and in
return type. See here: https
Hi,
Is it possible to view full stacktraces when task fails? Currently
only the last item in the stacktrace is printed to the terminal when I
run a failing program. I'm very surprised that I was not able to find
any information on this. It looks like that the problem is
nonexistent. However, the
, but we'd
need to start parsing DWARF etc. Not trivial.
On Sun, Jan 19, 2014 at 12:58 PM, Vladimir Matveev
dpx.infin...@gmail.com wrote:
Hi,
Is it possible to view full stacktraces when task fails? Currently
only the last item in the stacktrace is printed to the terminal when I
run a failing
Hi,
In fact, you're almost there. You only need to add lifetime
annotations on `Sprite` in the intermediate HashMap variable and in
return type. See here: https://gist.github.com/dpx-infinity/8516387
I tried to emulate rust-sfml types. This gist compiles, and the test
is successful. BTW, you
to the scoping
rules of macros, you don't need #[macro_escape] there---it's a child, so it
gets the macro. Only siblings, parents, uncles, aunts, cousins, c. would
need it.
On Jan 11, 2014 9:46 AM, Vladimir Matveev dpx.infin...@gmail.com wrote:
Hi,
As far as I understand, the current way
Hi,
As far as I understand, the current way to export macros is to
annotate the module with macro_rules definition with #[macro_escape]
annotation. But I just can't get it right, and my macro is not visible
in other module :(
Here is what I have:
- START -
/lib.rs:
I think I should have put my code to gist to track changes easily.
Amending: https://gist.github.com/dpx-infinity/6751843
2013/9/29 Vladimir Matveev dpx.infin...@gmail.com:
Yes, this is what I have observed too, see issue
https://github.com/mozilla/rust/issues/9597. I didn't know that using
As far as I understand, you're mostly right, except the structures bit.
Disregarding that it is not possible to use several lifetime
parameters yet, I see only one slight mistake: `s: MyStruct'a` does
not imply that `s` variable has any specific lifetime. If it is a
local variable, then it has
Hi all,
The problem I'm writing about in this message follows from the one I
have described in my other message:
https://mail.mozilla.org/pipermail/rust-dev/2013-August/005281.html .
I believe I'm now able to formulate it more clearly.
Consider the following example code:
trait Walker { //
continue to use
internal iterators, you just don't get the `for` syntax
anymore. Just write a higher-order function as you always did,
possibly returning bool to indicate whether to break or continue.
Niko
On Sat, Aug 17, 2013 at 01:54:09PM +0400, Vladimir Matveev wrote:
Hello,
I'm
Hello,
I'm writing a simple tokenizer which is defined by this trait:
trait Tokenizer {
fn next_token(mut self) - ~str;
fn eof(self) - bool;
}
Obvious application for a tokenizer is splitting a stream going from
Reader, so I have the following structure which should implement
Tokenizer:
40 matches
Mail list logo