uuid-rs / uuid

Generate and parse UUIDs.

Home Page:https://www.crates.io/crates/uuid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Idiotmatic naming: drop/replace `get_` prefixes

virtualritz opened this issue · comments

See "Getter names follow Rust convention (C-GETTER)".

Suggestion:

  1. Strip resp. functions of the get_ prefix.
  2. Create functions that have the old names and are marked #[deprecated()] and #[inline(always)] and have them plain call the stripped ones.
  3. If those functions had this prefix to indicate that they do work (vs. plain getters that just return a copy of a struct member), consider using the to_ prefix instead.

Specifically:

  • Uuid::get_timestamp()
  • Uuid::get_variant()
  • Uuid::get_version()
  • Uuid::get_version_num()

Thanks for the suggestion @virtualritz 👍 This has come up before and although those names are more idiomatic with modern Rust (and if I were writing them today I would definitely use to_ rather than get_), we opted not to churn them because they've already been in that form for years.

I understand.
Hence my suggestion with keeping the old names and adding deprecation warnings.

It's one of the perks of Rust that the language supports this natively. :]

Suffice to say I'd make a PR with those changes – if it had any chance of being accepted.

At some point I think we’ll probably release a semver compatible 2.0 that cleans up our module layout and feautes a bit. I think that would also be a good time to do this deprecation. In a major release you’d typically just make breaking changes, but for uuid I’m trying to maintain strict backwards compatibility so you can feel confident using Uuid in public APIs.

We don't have anything actionable here in the near future so I'll go ahead and close this one to keep our issue list current, but is something worth revisiting if we do come around to a 2.0