Functions that answer yes or no
Name: ratified 2026-10-18 (calef, "Yes"). Refused boolean-predicates.
An appendix to design/naming.md, which states the
rules. It holds the shapes in full, the prior art they follow, and the cases that need a judgment.
The rule
A function that answers a question and changes nothing takes one of these shapes, as Rust does:
is_before an adjective, participle or noun phrase:is_empty,is_tick_pending.has_before a thing held (has_unclosed_fence), orcan_before a verb (can_read).- A third-person verb phrase, std's shape for a relation:
contains,starts_with,overlaps,allows,needs_drop. A leading quantifier (all_,any_) reads asIterator::allandany.
A bare adjective, participle or noun (enabled, pending, present, truncated, read_only,
done, required) reads as a getter, and std spells those is_enabled.
Exempt:
- A function that acts and reports whether it worked:
insert,push,claim, atake_that clears a flag. Aboolreturn does not make a function a question. - Test functions, which read as sentences here, and fields (a field that is an array of booleans takes the predicate form: design/naming.md).
- A trait method or a name another project owns:
eq, std'sPermissions::readonlyin thestdoverlay, C-GETTER'sget. - An
externsymbol that assembly calls by name.
Why a verb phrase passes
std's relations read as a sentence with the receiver as subject: set.contains(x),
path.starts_with(p), waker.will_wake(other). A finite verb already says "this is a question",
which is the job is_ does for an adjective. So rights.allows(needed) and user_can_read(va) fit
as they stand, and is_allowing would be less Rust, not more. The test is grammatical: a finite
verb (allows, was_already_up, machine_has_no_rtc) passes, and an adjective, participle or noun
standing alone takes is_ or has_.
Cases that need a judgment
- Rust has no
are_. A plural subject still takesis_orhas_, asslice::is_sorteddoes:has_clocks_running, notare_clocks_running. - Adding
is_can leave a name that does not parse:is_shiftfor "is a shift key held", oris_aarch64on a set of legs whereAllalso answers yes. Choosing the words is a naming decision, so the function carries a/// Name: provisionalmarker with a recommendation (is_shift_held,includes_aarch64) and joinsscript/names --unratified. - A name that reads as a participle and acts (
removedsends an unlink,askedprompts for a reply) passes as an action, but a verb (remove,ask_to_confirm) would say so more plainly. is_on a by-value receiver is fine forCopytypes and warns under clippy otherwise, so a rename of aselfmethod takes&selfwhen the type is notCopy.
What Rust's convention is
Rust has no written rule for predicates. The API Guidelines' naming chapter (source)
covers casing, conversions, getters, iterators, features and word order, and its one is_ example
shows how to lowercase an acronym. RFC 430 and RFC 344 say nothing of booleans
either. Clippy's wrong_self_convention (source) checks the receiver of an is_ name and
never requires is_ on a function that returns bool.
So the convention is what std does. A regex census of every pub fn ... -> bool in core, alloc
and std (tests, sys and the intrinsics aside) found 342 functions: 236 is_, 45 relations
(contains, starts_with, eq, exists, needs_drop), 3 can_ and 2 has_. Most of the rest
are actions that report what happened (HashSet::insert, Vec::pop_if, AtomicBool::swap). What
remains are std's older exceptions (ExitStatus::success, thread::panicking,
Formatter::alternate), and newer stable API does not repeat them: Option::is_some_and,
slice::is_sorted. The rule follows what std converged on for a question, not what it keeps for
compatibility.
BUGS
helpers/name_checks.pylists aboolfunction outside the shapes, but only judgment tells a question from an action, so the check reads a first word ending insas a finite verb and a plural noun (bits_set) passes.- The std census reads source with a regex, not rustdoc, so its counts are close rather than exact.