GithubHelp home page GithubHelp logo

Comments (4)

andrewrk avatar andrewrk commented on September 27, 2024

Mutability is referring to whether any of the fields of face need to change when that method is called. Although some internal state might change in the freetype library code, the Face struct itself does not need to change.

from freetype-rs.

nstoddard avatar nstoddard commented on September 27, 2024

Some projects such as glfw-rs use &mut self even for methods that don't modify struct fields. See PistonDevelopers/glfw-rs@6b5c2fe for an example. It seems like we should follow that example. For one thing, it's conceivable that at some point we might want to change some of those methods so that they do change fields, which would require switching to &mut self anyway. I'd rather not risk having to break the API like that.

from freetype-rs.

bvssvni avatar bvssvni commented on September 27, 2024

I asked in #rust-internals about this, and was told the calling order of FFI functions won't be affected.

from freetype-rs.

bvssvni avatar bvssvni commented on September 27, 2024

This seems like an issue similar to when to use unsafe, which also has grey areas in library design. I can't tell which way is right, because there could be different contexts where either case is wrong. The argument in favor of using &mut self is that the API breaks less code when doing &mut self => &self, than &self => &mut self. If we suspect we will run into this issue and there is no context we can think of when &self is better, then I think we should use &mut self.

from freetype-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.