Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
NadiaIdris opened this issue Dec 5, 2023 · 0 comments
Open

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

NadiaIdris opened this issue Dec 5, 2023 · 0 comments
Labels
docs Improvements or additions to documentation

Comments

@NadiaIdris
Copy link
Contributor

NadiaIdris commented Dec 5, 2023

Add naming convention to code style guide (inside docs/contributing_guides/style_guide.md).

Option

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

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 NadiaIdris added the docs Improvements or additions to documentation label Dec 5, 2023
@NadiaIdris NadiaIdris changed the title [style-guide][docs] Add naming convention if type is Option [docs] Add naming convention if type is Option Dec 5, 2023
@nazmulidris nazmulidris changed the title [docs] Add naming convention if type is Option [docs] Add naming convention if type is Option or Result Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant