Hi,
when compiling following code with rust 0.10 I get following error:
use std::cmp;
struct vec2d { a:f32, b:f32 }
impl vec2d {
pub fn max(self) - f32 {
cmp::max(self.a, self.b)
}
}
test.rs:6:9: 6:17 error: failed to find an implementation of trait
std::cmp::TotalOrd for f32
A C-style array is written `*T`, much like in C (note: I'm not saying
`T*` and `T[]` are the same type, I know they aren't)
On Sat, Apr 5, 2014 at 6:53 AM, Simon Sapin simon.sa...@exyr.org wrote:
On 05/04/2014 11:39, Vladimir Pouzanov wrote:
The problem is that [extern unsafe fn()] results in
Ended up specifying array size as per Simon's suggestion:
#[link_section=.isr_vector_temp]
#[no_mangle]
pub static ISRVectors: [extern unsafe fn(), ..4] = [
_stack_base,
main,
isr_nmi,
isr_hardfault,
];
Given that table size is an architecture-dependent time constant, it also
adds a tiny
On 05/04/2014 12:00, Corey Richardson wrote:
A C-style array is written `*T`, much like in C (note: I'm not saying
`T*` and `T[]` are the same type, I know they aren't)
*T in Rust is not an array, it is a raw pointer. It may happen to point
to the start of an array that you could unsafely
On 05/04/2014 13:28, Vladimir Pouzanov wrote:
Also tried defining something along the lines of *[extern unsafe fn()],
but I guess size is also required in this case.
This will probably work once we have DST, but it will result in a
fixed-size pointer to an array, rather than the actual array
On 05/04/14 09:23 AM, Simon Sapin wrote:
On 05/04/2014 14:14, Corey Richardson wrote:
Sure, same thing as a C-style array, minus the fact that we don't have
Index implemented for unsafe ptrs.
Sure, but that difference is the important part. It’s idiomatic C to
pretend that a pointer is like
Hello everyone,
I have a question about making extension methods on something like
io::Writer. Basically, I have a data format that requires strings to be
serialized as an 8-byte length header and then the string bytes themselves.
Instead of having to type writer.write_u64(...);
On Fri, Apr 4, 2014 at 10:41 PM, Philippe Delrieu
philippe.delr...@free.fr wrote:
Hello,
I've some problem to find a solution for something I want to do with a
vector of enum. This is an example of what I want to do:
trait Base{
fn set_something(mut self);
}
struct FirstThink;
You can do it like this:
implT: Writer MySerialization for T {
...
}
Steven Fackler
On Sat, Apr 5, 2014 at 12:57 PM, Frank Huang m...@nongraphical.com wrote:
Hello everyone,
I have a question about making extension methods on something like
io::Writer. Basically, I have a data format
Very good idea. The vector don't have to be modified so it'll work.
Thank you for the advice. I make a try an I'll post the result.
Philippe
Le 05/04/2014 21:59, Rodrigo Rivas a écrit :
On Fri, Apr 4, 2014 at 10:41 PM, Philippe Delrieu
philippe.delr...@free.fr wrote:
Hello,
I've some
Thanks for the quick response, Steven! Having done what you suggested, I'm
now getting the following error (for serializing a larger struct in which
some fields are strings):
implT: Writer MySerialization for T {
fn write_my_string(mut self, s: str) - IoResult() {
...
}
}
impl
I can't say why the immutable argument error is happening, but there's
another error in that function. You're using a `Writer`, but Writer doesn't
have `write_my_string`, only `MySerialization` does. I'd write that like
this:
fn save_toT: MySerialization(self, writer: mut T) - io::IoResult() {
Try this:
On 4/5/14 1:55 PM, Frank Huang wrote:
implT: Writer MySerialization for T {
fn write_my_string(mut self, s: str) - IoResult() {
...
}
}
impl StructToBeSerialized {
fn save_to(self, mut writer: mut io::Writer) - io::IoResult() {
13 matches
Mail list logo