will generate:
--> src/main.rs:42:9
|
42 | graphics::draw(
| ^^^^^^^^^^^^^^ the trait std::convert::From<nalgebra::geometry::point::Point<f32, nalgebra::base::dimension::U2>> is not implemented for ggez::graphics::drawparam::DrawParam
Suggestions: help: the following implementations were found: <ggez::graphics::drawparam::DrawParam as std::convert::From<(P, f32, P, V, ggez::graphics::types::Color)>> <ggez::graphics::drawparam::DrawParam as std::convert::From<(P, f32, P, ggez::graphics::types::Color)>> <ggez::graphics::drawparam::DrawParam as std::convert::From<(P, f32, ggez::graphics::types::Color)>> <ggez::graphics::drawparam::DrawParam as std::convert::From<(P, ggez::graphics::types::Color)>> <ggez::graphics::drawparam::DrawParam as std::convert::From<(P,)>> = note: required because of the requirements on the impl ofstd::convert::Intoggez::graphics::drawparam::DrawParamfornalgebra::geometry::point::Point<f32, nalgebra::base::dimension::U2>
I looked up the docs for Point2 and drawparam::Drawable but can't interpret that error.
Edit: I am asking about how to interpret the error because the compiler has been very clear so far with why the code was wrong and what I would need to do about it, but I don't get the suggestion this time.
One-element tuples require a comma to disambiguate them from grouping parenthesis, so ( x ,) is a tuple but ( x ) is whatever type x is.
This says that this call graphics::draw requires DrawParam to implement the trait From<Point<f32, U2>> (path components removed for clarity). You are passing a value of type Point<f32, U2>, which cannot be converted into DrawParam.
Next comes a list of related types that the conversion is implemented for, in case you meant one of them:
(P, f32, P, V, ggez::graphics::types::Color)
(P, f32, P, ggez::graphics::types::Color)
(P, f32, ggez::graphics::types::Color)
(P, ggez::graphics::types::Color)
(P,)
Finally, it says where the From requirement originated. In this case, the parameter is required to implement Into, and the compiler found that the blanket implementation required From:
= note: required because of the requirements on the impl of Into<DrawParam> for Point<f32, U2>
That’s what this error is. It’s long-winded because the function is generic and there are lots of “correct” types: any of the tuples on the list I gave will work, and the compiler doesn’t know which you might need.
There are more that will work, too— these are just the ones related to the type you tried to use.
In the next tutorial they are using another math crate. It also generates this error.
So here to make it work I would need to replace the cgmath by a mint::vector?
Problem: graphics::draw(ctx, &self.text, (dest_point,))?; | ^^^^^^^^^^^^^^ the trait std::convert::From<cgmath::point::Point2<f32>> is not implemented for mint::vector::Point2<f32>
Hints:
480 | T: Into<DrawParam>, | --------------- required by this bound in ggez::graphics::draw | = help: the following implementations were found: <mint::vector::Point2<T> as std::convert::From<[T; 2]>> <mint::vector::Point2<T> as std::convert::From<mint::vector::Vector2<T>>> = note: required because of the requirements on the impl ofstd::convert::Into<mint::vector::Point2>forcgmath::point::Point2 = note: required because of the requirements on the impl ofstd::convert::From<(cgmath::point::Point2,)>forggez::graphics::drawparam::DrawParam = note: required because of the requirements on the impl ofstd::convert::Intoggez::graphics::drawparam::DrawParamfor(cgmath::point::Point2,)`
EDIT: Holy crap, there were a lot of trial and error there. Thanks for your kind explanation and clarifications, in the end I could offer a type of Point2 that the compiler accepted:
let dest_point = mint::Point2 {
x: (offset),
y: (offset),
};