I find that I can't use runtime values inside the pattern, I can only match on a range made of compile-time constants.
Therefore, I add the function in_range to judge it.
The Point from embedded_graphics can't use try_into? So I add a From to change it to Position.
The impl OriginDimensions is from example of embedded_graphics official:
This trait should be implemented instead of Dimensions if the top left corner of the bounding box will always be at the origin, which will be the case for most display drivers. Some types, like [ImageDrawable], require a bounding box that starts at the origin and can only be used if OriginDimensions is implemented.
enable it to print "Hello Rust!" on qemu:
I find that I can't use runtime values inside the pattern, I can only match on a range made of compile-time constants.
Therefore, I add the function
in_range
to judge it.The
Point
from embedded_graphics can't usetry_into
? So I add aFrom
to change it to Position.The
impl OriginDimensions
is from example of embedded_graphics official:Anyway, now, It works.