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

[Feature Request] implement AsRangedCoord for RangeInclusive<A> #514

Open
softmoth opened this issue Oct 21, 2023 · 0 comments
Open

[Feature Request] implement AsRangedCoord for RangeInclusive<A> #514

softmoth opened this issue Oct 21, 2023 · 0 comments

Comments

@softmoth
Copy link

What is the feature ?

Add an implementation of AsRangedCoord for RangeInclusive.

It would allow charts to label the final tick mark at the right/top edge of the mesh, rather than having a weird blank spot there.

This doesn't work currently:

error[E0599]: the method `step` exists for struct `RangeInclusive<{float}>`, but its trait bounds were not satisfied
   --> src/bin/plot2.rs:51:44
    |
51  |         .build_cartesian_2d((-20.0..=20.0).step(0.5), -10..50)
    |                                            ^^^^ method cannot be called on `RangeInclusive<{float}>` due to unsatisfied trait bounds
    |
   ::: /home/trs/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/range.rs:341:1
    |
341 | pub struct RangeInclusive<Idx> {
    | ------------------------------
    | |
    | doesn't satisfy `RangeInclusive<{float}>: AsRangedCoord`
    | doesn't satisfy `_: IntoLinspace`
    |
    = note: the following trait bounds were not satisfied:
            `RangeInclusive<{float}>: AsRangedCoord`
            which is required by `RangeInclusive<{float}>: plotters::prelude::IntoLinspace`
            `&RangeInclusive<{float}>: AsRangedCoord`
            which is required by `&RangeInclusive<{float}>: plotters::prelude::IntoLinspace`
            `&mut RangeInclusive<{float}>: AsRangedCoord`
            which is required by `&mut RangeInclusive<{float}>: plotters::prelude::IntoLinspace`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `mip` (bin "plot2") due to previous error

Workaround

A workaround is to use (-20.0..20.000_001).step(0.5), which is a bit of a hassle but does look okay.

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

No branches or pull requests

1 participant