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
t
Floating point numbers don't have a total ordering (all of these are
false: NaN < NaN, NaN == NaN, NaN > NaN).
Use the floating-point specific method, `self.a.max(self.b)`.
Huon
On 05/04/14 19:30, Rémi Fontan wrote:
Hi,
when compiling following code with rust 0.10 I get following error:
us
ok, got it.
thanks
Rémi
On Sat, Apr 5, 2014 at 9:34 PM, Huon Wilson wrote:
> Floating point numbers don't have a total ordering (all of these are
> false: NaN < NaN, NaN == NaN, NaN > NaN).
>
> Use the floating-point specific method, `self.a.max(self.b)`.
>
>
> Huon
>
>
> On 05/04/14 19:30,
The problem is that &[extern unsafe fn()] results in 8 bytes, pointer to
the actual array and its size. Is there any way I can get a plain C-style
array in rust?
On Fri, Apr 4, 2014 at 9:06 PM, Alex Crichton wrote:
> As you've discovered in bug #13325, dealing with external constants in
> stati
On 05/04/2014 11:39, Vladimir Pouzanov wrote:
The problem is that &[extern unsafe fn()] results in 8 bytes, pointer to
the actual array and its size. Is there any way I can get a plain
C-style array in rust?
If the size is known as compile-time you can use:
static table: [extern unsafe fn(), .
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 wrote:
> On 05/04/2014 11:39, Vladimir Pouzanov wrote:
>>
>> The problem is that &[extern unsafe fn()] results in 8 bytes, pointe
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 tin
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 acce
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 l
Sure, same thing as a C-style array, minus the fact that we don't have
Index implemented for unsafe ptrs.
On Sat, Apr 5, 2014 at 9:07 AM, Simon Sapin wrote:
> 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[]`
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 an array, but not in Rust.
--
Simon Sapin
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
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(...); writer.write_str
On Fri, Apr 4, 2014 at 10:41 PM, Philippe Delrieu
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;
>
> impl Base for
You can do it like this:
impl MySerialization for T {
...
}
Steven Fackler
On Sat, Apr 5, 2014 at 12:57 PM, Frank Huang wrote:
> 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
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
wrote:
Hello,
I've some problem to find a solution for
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):
impl MySerialization for T {
fn write_my_string(&mut self, s: &str) -> IoResult<()> {
...
}
}
impl StructToBeSeria
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_to(&self, writer: &mut T) -> io::IoResult<()> {
writer.write
Try this:
On 4/5/14 1:55 PM, Frank Huang wrote:
impl 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<()> {
try!(writer.write_my_string(self.stri
19 matches
Mail list logo