Skip to content

Decide on a naming convention for casting methods. #7151

Closed
@Kimundi

Description

@Kimundi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions