Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error[E0599]: no method named to_f32 found for struct euclid::Rect<Au, LayoutPixel> in the current scope #46

Open
kaiwk opened this issue Sep 28, 2020 · 3 comments

Comments

@kaiwk
Copy link

kaiwk commented Sep 28, 2020

I want to convert au_rect: Rect<Au, LayoutPixel> to f32_rect: Rect<f32, LayoutPixel> by au_rect.to_f32(), as the compiler prompts:

26 | pub struct Au(pub i32);
   | ----------------------- doesn't satisfy `Au: num_traits::cast::NumCast`
   |
   = note: the method `to_f32` exists but the following trait bounds were not satisfied:
           `Au: num_traits::cast::NumCast`

Can we just impl NumCast for Au?

@emilio
Copy link
Member

emilio commented Sep 28, 2020

Hmm, do you expect the target rect to be in actual pixels I guess? (as in, the equivalent to to_f32_px()?)

I think NumCast can be confusing, because you may want the Au value as f32 (so value.0 as f32 or such), or the actual pixel value as f32 (value.as_f32_px())

@kaiwk
Copy link
Author

kaiwk commented Sep 28, 2020

as in, the equivalent to to_f32_px()?

Yes, exactly. It seems there is no way to convert the Rect<Au> directly.

because you may want the Au value as f32 (so value.0 as f32 or such)

ha, I see.

@mrobinson
Copy link
Member

I think NumCast can be confusing, because you may want the Au value as f32 (so value.0 as f32 or such), or the actual pixel value as f32 (value.as_f32_px())

Out of curiosity, when is it useful to have value.0 as f32?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants