Skip to content

[rfc] [style] define generics with single characters when possibleΒ #1

@merklefruit

Description

@merklefruit

Generics on struct should when possible use a single letter. Example:

pub struct ExecutionClient<C, P> {
	provider: DefaultProvider,
	chain: PhantomData<C>,
	pubsub: PhantomData<P>
}

instead of:

pub struct ExecutionClient<CHAIN, PUBSUB> {
	provider: DefaultProvider,
	chain: PhantomData<CHAIN>,
	pubsub: PhantomData<PUBSUB>
}

If two generics have semantics that make them hard to distinguish with a single letter, then we should use two letters to disambiguate.
For instance, a struct with a Provider and PubSub generics could become P and PS or similar. There is no strict rule here, but the guideline is to use identifiers that are short yet clear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions