Documentation uses terms "source" and "target" to describe "self" and "other" #480

Closed
opened 2026-04-03 19:29:28 -05:00 by kornelski · 2 comments
kornelski commented 2026-04-03 19:29:28 -05:00 (Migrated from github.com)

The rustdoc reference looks like this:

fn contains(&self, other: Self) -> bool
where
    Self: Sized,

Whether all set bits in a source flags value are also set in a target flags value.

The function takes self and other arguments, but the doc comment defines it in terms of a source and target. It's not specified which argument is the source and which one is the target. Is it source.contains(target) or target.contains(source)?

The [rustdoc reference](https://docs.rs/bitflags/latest/bitflags/trait.Flags.html#method.contains) looks like this: > ```rust > fn contains(&self, other: Self) -> bool > where > Self: Sized, > ``` > Whether all set bits in a **source** flags value are also set in a **target** flags value. The function takes `self` and `other` arguments, but the doc comment defines it in terms of a `source` and `target`. It's not specified which argument is the source and which one is the target. Is it `source.contains(target)` or `target.contains(source)`?
KodrAus commented 2026-04-10 05:54:19 -05:00 (Migrated from github.com)

Thanks for the note @kornelski. This could definitely be improved. The wording in the docs is to match what's in the spec so the naming is consistent, but would simply be better written as whether self contains other.

Thanks for the note @kornelski. This could definitely be improved. The wording in the docs is to match what's [in the spec](https://github.com/bitflags/bitflags/blob/main/spec.md) so the naming is consistent, but would simply be better written as _whether `self` contains `other`_.
kornelski commented 2026-04-12 16:14:35 -05:00 (Migrated from github.com)

I interact with the library through rust-analyzer, so I haven't even known there was a spec. Jump to definition unfortunately jumps to an opaque macro that doesn't even show the boolean algebra behind it.

I interact with the library through rust-analyzer, so I haven't even known there was a spec. Jump to definition unfortunately jumps to an opaque macro that doesn't even show the boolean algebra behind it.
Sign in to join this conversation.
No labels
bug
good first issue
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-bitflags/bitflags#480
No description provided.