r3bl-open-core icon indicating copy to clipboard operation
r3bl-open-core copied to clipboard

[docs] Add naming convention if type is Option or Result

Open NadiaIdris opened this issue 1 year ago • 0 comments

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) => {...}
}

NadiaIdris avatar Dec 05 '23 04:12 NadiaIdris