Pluralization in APIs (Guideline?)

I wonder if there's any recommendation on whether to use pluralization in module names. The Rust API Guidelines don't seem to mention anything.

I noticed that it's std::array but std::collections (note the singular in the first case and the plural form in the second case). Maybe that's because there is only one kind of array (basically), but several types being collections?

The reason I'm asking is because I want to move some error types to a submodule, and I'm not sure whether I should name it error (as in std::error or io::error) or errors. I tend to name it errors, even though generally I dislike pluralization in programs, type names, SQL tables, etc.

2 Likes

Regarding the pluralisation in std::collections, it could be as simple as "that's what other languages do" (e.g. C#'s System.Collections).

Personally, if there is one "main" component in the module I would leave it singular (e.g. std::array, std::error), but if there are multiple main components in a module I would make it plural (e.g. std::collections, std::ops). Of course, in the real world you'll find just as many exceptions as conforming names (std::marker, std::primitive, std::hint, etc.).

I think people just go with the name that feels right at the time, tbh.

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.