From 9e932268a5b4b97e93735ddd06bf1619ca696f27 Mon Sep 17 00:00:00 2001 From: Jonathan Reem Date: Fri, 9 May 2014 13:31:50 -0700 Subject: [PATCH] Many small grammar and typo fixes. No content changed. --- Note-style-guide.md | 57 ++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/Note-style-guide.md b/Note-style-guide.md index 3591058..304f86c 100644 --- a/Note-style-guide.md +++ b/Note-style-guide.md @@ -1,4 +1,4 @@ -Here are some rough guidelines to Rust style. They are followed unevenly and there's not necessarily consensus about everything here. More work is required. +Here are some rough guidelines to Rust style. They are followed unevenly and there's not necessarily a consensus about everything in here. More work is required. # Editor settings @@ -13,16 +13,16 @@ Here are some rough guidelines to Rust style. They are followed unevenly and the * Acronyms should be camel case, too: `Uuid`, not `UUID`. * Functions, methods, and variables should be `lowercase_with_underscores` where it helps readability. * Static variables should be in `ALL_CAPS`. -* Constructors are methods called `new` or `new_with_more_details`. -* Constructors that simply convert from another type are methods called `from_foo`. +* Constructors should be methods called `new` or `new_with_more_details`. +* Constructors that simply convert from another type should be methods called `from_foo`. * When writing a binding to an external library, put the raw C bindings in a module called `ffi` (rather than `ll`). Do not create high-level bindings called `hl`. -* lifetime names are lowercase and are often simply 'a +* lifetime names should be lowercase and are often simply 'a ## Trait naming - trait examples: Copy, Owned, Const, Add, Sub, Num, Shr, Index, Encode, Decode, Reader, Writer, GenericPath - extension traits: FooUtil. However, prefer default methods to extension traits. -- avoid words with suffixes (able, etc). try to use transitive verbs, nouns, and then adjectives in that order +- avoid words with suffixes (able, etc). Try to use transitive verbs, nouns, and then adjectives in that order. ## Converting between types Functions for converting between types should attempt to follow this: @@ -35,13 +35,13 @@ These are not hard rules, since generically implemented functions mean that an ` ## Iterators -Naming iterators are often a little tricky because their names can get quite verbose quite quickly. Since #11001 landed, we've standardized on iterator naming conventions. When naming an iterator, follow these rules from top-to bottom (short circuiting when you hit a relevant one). +Naming iterators is often a little tricky because their names can get quite verbose very quickly. Since #11001 landed, we've standardized iterator naming conventions. When naming an iterator, follow these rules from top-to bottom (short circuiting when you hit a relevant one). -1. If the iterator is yielding something that can be described with a noun, the iterator should be called the pluralization of the noun (an iterator yielding words is called Words) -2. An iterator over the members of a container should have the base name of `Items`, with different flavors deriving from this name. Different flavors are applied in order of top-to-bottom in this list - * Moving iterators have the prefix of `Move` - * If the default iterator yields an immutable reference, an iterator yielding a mutable reference has the prefix `Mut` - * Reverse iterators have the prefix of `Rev` +1. If the iterator yields something that can be described with a noun, the iterator should be called the pluralization of that noun (e.g. an iterator yielding words is called Words) +2. An iterator over the members of a container should have a base name of `Items`, with different flavors deriving from this name. Different flavors are applied top-to-bottom from this list + * Moving iterators have a prefix of `Move` + * If the default iterator yields an immutable reference, an iterator yielding a mutable reference has a prefix `Mut` + * Reverse iterators have a prefix of `Rev` 3. If these rules would result in a name that might cause confusion, pick a less confusing name. These rules are a little vague, and that's partly on purpose. The general idea is to be concise and consistent. Examples through libstd and libextra should showcase how we expect iterators to be named. @@ -68,7 +68,7 @@ fn foo