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

Follow the Rust API Guidelines - Checklist #25

Closed
54 tasks done
madsmtm opened this issue Sep 5, 2021 · 6 comments
Closed
54 tasks done

Follow the Rust API Guidelines - Checklist #25

madsmtm opened this issue Sep 5, 2021 · 6 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Milestone

Comments

@madsmtm
Copy link
Owner

madsmtm commented Sep 5, 2021

Rust API Guidelines Checklist

  • Naming (crate aligns with Rust naming conventions)
    • Casing conforms to RFC 430 (C-CASE)
    • Ad-hoc conversions follow as_, to_, into_ conventions (C-CONV)
    • Getter names follow Rust convention (C-GETTER)
    • Methods on collections that produce iterators follow iter, iter_mut, into_iter (C-ITER)
    • Iterator type names match the methods that produce them (C-ITER-TY)
    • Feature names are free of placeholder words (C-FEATURE)
    • Names use a consistent word order (C-WORD-ORDER)
  • Interoperability (crate interacts nicely with other library functionality)
    • Types eagerly implement common traits (C-COMMON-TRAITS)
      • Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug,
        Display, Default
    • Conversions use the standard traits From, AsRef, AsMut (C-CONV-TRAITS)
    • Collections implement FromIterator and Extend (C-COLLECT)
    • Data structures implement Serde's Serialize, Deserialize (C-SERDE)
      • I'm afraid of getting a circular dependency tree in the future if we do this (e.g. we rely on serde, and at some point, through their own deps, they rely on us)
    • Types are Send and Sync where possible (C-SEND-SYNC)
    • Error types are meaningful and well-behaved (C-GOOD-ERR)
    • Binary number types provide Hex, Octal, Binary formatting (C-NUM-FMT)
      • Doesn't make sense for Bool, just as we don't implement PartialEq for that
    • Generic reader/writer functions take R: Read and W: Write by value (C-RW-VALUE)
  • Macros (crate presents well-behaved macros)
  • Documentation (crate is abundantly documented)
  • Predictability (crate enables legible code that acts how it looks)
    • Smart pointers do not add inherent methods (C-SMART-PTR)
    • Conversions live on the most specific type involved (C-CONV-SPECIFIC)
    • Functions with a clear receiver are methods (C-METHOD)
    • Functions do not take out-parameters (C-NO-OUT)
    • Operator overloads are unsurprising (C-OVERLOAD)
    • Only smart pointers implement Deref and DerefMut (C-DEREF)
      • Note: Intentionally ignored, and documented as such.
    • Constructors are static, inherent methods (C-CTOR)
  • Flexibility (crate supports diverse real-world use cases)
  • Type safety (crate leverages the type system effectively)
    • Newtypes provide static distinctions (C-NEWTYPE)
    • Arguments convey meaning through types, not bool or Option (C-CUSTOM-TYPE)
    • Types for a set of flags are bitflags, not enums (C-BITFLAG)
    • Builders enable construction of complex values (C-BUILDER)
  • Dependability (crate is unlikely to do the wrong thing)
  • Debuggability (crate is conducive to easy debugging)
  • Future proofing (crate is free to improve without breaking users' code)
  • Necessities (to whom they matter, they really matter)
    • Public dependencies of a stable crate are stable (C-STABLE)
    • Crate and its dependencies have a permissive license (C-PERMISSIVE)
@madsmtm madsmtm added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 5, 2021
@madsmtm madsmtm self-assigned this Sep 5, 2021
@madsmtm
Copy link
Owner Author

madsmtm commented Sep 5, 2021

Also, investigate using ToOwned.

@madsmtm madsmtm mentioned this issue Sep 5, 2021
80 tasks
@madsmtm
Copy link
Owner Author

madsmtm commented Oct 15, 2021

I think we want to keep breaking C-SMART-PTR for Id::autorelease because that is a method name that only ever makes sense on Id

@madsmtm
Copy link
Owner Author

madsmtm commented Nov 2, 2021

#![warn(missing_debug_implementations)] can be helpful here

@madsmtm madsmtm changed the title Follow the Rust API Guidelines Checklist Follow the Rust API Guidelines - Checklist Nov 22, 2021
@madsmtm
Copy link
Owner Author

madsmtm commented Apr 1, 2022

We should also check all traits for whether they provide correct blanket impls (impl<T: Trait> Trait for &T, Box<T>, ...)

@madsmtm madsmtm added this to the objc2 v0.3 milestone May 25, 2022
@madsmtm madsmtm modified the milestones: objc2 v0.4, icrate v0.1.0 Apr 21, 2023
@madsmtm
Copy link
Owner Author

madsmtm commented May 26, 2023

I will consider most of this guideline as not really applicable to icrate, since most of the design questions there are handled by Apple, and not us.

Naming decisions in icrate are explicitly moved to #284

@madsmtm
Copy link
Owner Author

madsmtm commented Sep 4, 2023

I consider this basically done now, remaining parts are tracked in the linked issues

@madsmtm madsmtm closed this as completed Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant