Skip to content

Latest commit

 

History

History
111 lines (84 loc) · 2.04 KB

File metadata and controls

111 lines (84 loc) · 2.04 KB

Hello world, this is iris-utilities!

Contributing

When contributing to I.R.I.S. Utilities, please follow these guidelines:

  1. Demonstrate the Code of Conduct.
  2. Open an issue before opening a pull request (unless for bug fixes, security patches, grammatical corrections, or simple changes).
  3. Keep your pull request short and simple. Try to not include unrelated or biased changes.
  4. Maintain compatibility with the License.
  5. Follow the Code Style Guide.

Code Style Guide

Implicit returns.

fn example_function() -> String {
    // note the lack of a semicolon and `return` keyword
    "example".to_string()
}

Short chains and long chains.

// note how the entire chain fits on one line
let result = short_function().short_method().await;

// note how the first method call starts on the next line
// and how `.await` is on the same line as the method call
let result =
    long_function()
    .long_method().await
    .do_something().await;

Types, enums, structs.

type ExampleType = i32;

enum ExampleEnum {
    ExampleKey,
}

struct ExampleStruct {}

Functions, methods, and lambdas.

fn example_function(
    example_parameter: ExampleType,
) -> ExampleType {
    example_parameter
}

impl ExampleStruct {
    fn example_method(
        &self,
        example_parameter: ExampleType,
    ) -> ExampleType {
        example_parameter
    }
}

let example_lambda = |condition: bool| -> i32 {
    if condition {
        1
    } else {
        0
    }
};

Variables and properties.

const EXAMPLE_CONSTANT: i32 = 1;

let example_variable = 1;

struct ExampleStruct {
    example_property: i32,
}

Comments.

// Single-line comment.

// Multi-line
// comment.

/// Documentation comment.
/// This is a documentation comment.

Whitespace, indentation, and newlines.

if
    long_condition &&
    another_long_condition
{
    // Indentation is 4 spaces.
    // Braces are on the same line.
}