r3bl-open-core
r3bl-open-core copied to clipboard
[docs] Add naming convention if type is Option or Result
Add naming convention to code style guide (inside docs/contributing_guides/style_guide.md
).
Option<T>
If value of type Option<T>
, then prepend the variable name with maybe_...
, since the value can be None
or Some
.
For example:
let maybe_selected_branches: Option<Vec<String>> = ask_user_to_select_from_list(
branches,
ask_to_select_branches_header,
SelectionMode::Multiple,
);
match maybe_selected_branches {
Some(branches) => {...},
None => {}
}
Result<T>
If value is of type is Result<T>
, then prepend the variable name with result_...
, since the value can be Err
or Ok
.
For example:
let result_json_data: Result<String, Box<dyn Err>> = perform_fetch_call(...);
match result_json_data {
Ok(json_data) => {...},
Err(error) => {...}
}