Skip to content

Decide on a naming convention for casting methods. #7151

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

Closed
Kimundi opened this issue Jun 15, 2013 · 2 comments
Closed

Decide on a naming convention for casting methods. #7151

Kimundi opened this issue Jun 15, 2013 · 2 comments

Comments

@Kimundi
Copy link
Member

Kimundi commented Jun 15, 2013

There are often situations where you need similar-but-distinct names for functions that allow you to

  • convert &self to &T for some T != Self
  • convert self to T for some T != Self
  • copy &self to T for some T != Self

Those functions at the moment are named in a very ad-hoc fashion: to_bytes(), slice_str(), as_char(), to_bytes_consume() etc. A standard naming convention would allow to see at a glance what the function does.

One possible set of names could be:

  • to_TYPE() for a copy/new allocation.
  • as_TYPE() for a reference/slice.
  • into_TYPE() for consuming self and returning the target type without copy.
@thestinger
Copy link
Contributor

There's still no consistent convention across the codebase.

@erickt
Copy link
Contributor

erickt commented Sep 12, 2013

Closing this in favor of #7087, which has a longer discussion.

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

No branches or pull requests

3 participants