Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

PSA: Changing case of FIDL Rust bits members

9 views
Skip to first unread message

Zachary Stewart

unread,
Jan 21, 2022, 2:19:37 PM1/21/22
to fidl...@fuchsia.dev, rust-...@fuchsia.dev

If you don’t write Rust code using FIDL bindings, you can stop reading.

TL;DR

Rust FIDL bindings will now use SCREAMING_SNAKE_CASE for bits members instead of CamelCase.

No Action Required

You do not need to update existing code. I will fix all existing code in https://fxrev.dev/634125. However, if you have a Rust CL in progress, you might need to manually fix code that refers to bits members.

Background

The FIDL style guide recommends ALL_CAPS for both enum and bits members:

type Foo = enum {

    ONE = 1;

    TWO = 2;

};

type Bar = bits {

    ONE = 0x1;

    TWO = 0x2;

};


To align with Rust style, we convert enum members to CamelCase when generating Rust bindings. However, we also converted bits members to CamelCase, which was incorrect because bits are associated constants, not enum variants.

This change will switch how we generate bits constants to instead use SCREAMING_SNAKE_CASE, in order to align with Rust style. See https://fxbug.dev/47034 for more details.

Reply all
Reply to author
Forward
0 new messages