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

Add nighly support for constant floating point arithmetic #88

Open
deeprobin opened this issue Oct 7, 2021 · 2 comments
Open

Add nighly support for constant floating point arithmetic #88

deeprobin opened this issue Oct 7, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@deeprobin
Copy link
Contributor

Make functions const, which use floating point arithmetic

Example Proposal

https://github.com/mooman219/fontdue/blob/master/src/font.rs#L45-L53

Before

    #[inline(always)]
    pub fn scale(&self, scale: f32) -> OutlineBounds {
        OutlineBounds {
            xmin: self.xmin * scale,
            ymin: self.ymin * scale,
            width: self.width * scale,
            height: self.height * scale,
        }
    }

After

#![feature(const_fn_floating_point_arithmetic)]
// ...

    pub const fn scale(&self, scale: f32) -> OutlineBounds {
        OutlineBounds {
            xmin: self.xmin * scale,
            ymin: self.ymin * scale,
            width: self.width * scale,
            height: self.height * scale,
        }
    }
@mooman219 mooman219 added the enhancement New feature or request label Oct 8, 2021
@mooman219
Copy link
Owner

mooman219 commented Oct 8, 2021

Something to keep an eye on, but I'm not interested in nightly only features in Fontdue, even if there was a PR for it.
Looks promising for when it hits stable.

@deeprobin
Copy link
Contributor Author

There are still a few things to do in the associated tracking issue (rust-lang/rust#57241), but guess it won't be long before this becomes stable.

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

No branches or pull requests

2 participants