Skip to content

Commit d117272

Browse files
softpropsdavidbarsky
authored andcommitted
Ensure a consistent style for all changes (#51)
1 parent 48c5039 commit d117272

File tree

10 files changed

+38
-34
lines changed

10 files changed

+38
-34
lines changed

.rustfmt.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#merge_imports
12
merge_imports = true
3+
# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#max_width
24
max_width = 120

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ cache:
77
before_cache:
88
- rm -rf /home/travis/.cargo/registry
99

10+
install: |
11+
# this project's rustfmt style requires nightly features
12+
if [[ "$TRAVIS_RUST_VERSION" == nightly ]]; then
13+
rustup component add rustfmt
14+
fi
15+
1016
matrix:
1117
include:
1218
- rust: 1.31.0
@@ -18,5 +24,9 @@ matrix:
1824
- env: TARGET=x86_64-unknown-linux-musl
1925
- env: TARGET=x86_64-unknown-linux-gnu
2026
script:
27+
- |
28+
if [[ "$TRAVIS_RUST_VERSION" == nightly ]]; then
29+
cargo fmt --all -- --check
30+
fi
2131
- cargo build --verbose --all
2232
- cargo test --verbose --all

CONTRIBUTING.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Contributing Guidelines
22

3-
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
3+
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
44
documentation, we greatly value feedback and contributions from our community.
55

6-
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
6+
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
77
information to effectively respond to your bug report or contribution.
88

99

1010
## Reporting Bugs/Feature Requests
1111

1212
We welcome you to use the GitHub issue tracker to report bugs or suggest features.
1313

14-
When filing an issue, please check [existing open](https://github.com/awslabs/aws-lambda-rust-runtime/issues), or [recently closed](https://github.com/awslabs/aws-lambda-rust-runtime/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already
14+
When filing an issue, please check [existing open](https://github.com/awslabs/aws-lambda-rust-runtime/issues), or [recently closed](https://github.com/awslabs/aws-lambda-rust-runtime/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already
1515
reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
1616

1717
* A reproducible test case or series of steps
@@ -32,21 +32,21 @@ To send us a pull request, please:
3232
1. Fork the repository.
3333
2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
3434
3. Ensure local tests pass.
35-
4. Commit to your fork using clear commit messages.
35+
4. Commit to your fork using clear commit messages and ensure any Rust source files have been formatted with the [rustfmt tool](https://github.com/rust-lang/rustfmt#quick-start)
3636
5. Send us a pull request, answering any default questions in the pull request interface.
3737
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
3838

39-
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
39+
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
4040
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
4141

4242

4343
## Finding contributions to work on
44-
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/awslabs/aws-lambda-rust-runtime/labels/help%20wanted) issues is a great place to start.
44+
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/awslabs/aws-lambda-rust-runtime/labels/help%20wanted) issues is a great place to start.
4545

4646

4747
## Code of Conduct
48-
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
49-
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
48+
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
49+
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
5050
[email protected] with any additional questions or comments.
5151

5252

lambda-http/src/ext.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use serde::{de::value::Error as SerdeError, Deserialize};
66
use serde_json;
77
use serde_urlencoded;
88

9-
use crate::request::RequestContext;
10-
use crate::strmap::StrMap;
9+
use crate::{request::RequestContext, strmap::StrMap};
1110

1211
/// API gateway pre-parsed http query string parameters
1312
pub(crate) struct QueryStringParameters(pub(crate) StrMap);
@@ -157,9 +156,7 @@ mod tests {
157156
use serde_derive::Deserialize;
158157
use std::collections::HashMap;
159158

160-
use crate::GatewayRequest;
161-
use crate::RequestExt;
162-
use crate::StrMap;
159+
use crate::{GatewayRequest, RequestExt, StrMap};
163160

164161
#[test]
165162
fn requests_have_query_string_ext() {

lambda-http/src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,8 @@ pub mod request;
5555
mod response;
5656
mod strmap;
5757

58-
pub use crate::body::Body;
59-
pub use crate::ext::RequestExt;
60-
use crate::request::GatewayRequest;
61-
use crate::response::GatewayResponse;
62-
pub use crate::response::IntoResponse;
63-
pub use crate::strmap::StrMap;
58+
pub use crate::{body::Body, ext::RequestExt, response::IntoResponse, strmap::StrMap};
59+
use crate::{request::GatewayRequest, response::GatewayResponse};
6460

6561
/// Type alias for `http::Request`s with a fixed `lambda_http::Body` body
6662
pub type Request = http::Request<Body>;

lambda-http/src/request.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ use serde::{
1515
use serde_derive::Deserialize;
1616
use serde_json::Value;
1717

18-
use crate::body::Body;
19-
use crate::ext::{PathParameters, QueryStringParameters, StageVariables};
20-
use crate::strmap::StrMap;
18+
use crate::{
19+
body::Body,
20+
ext::{PathParameters, QueryStringParameters, StageVariables},
21+
strmap::StrMap,
22+
};
2123

2224
/// Representation of an API Gateway proxy event data
2325
#[doc(hidden)]

lambda-runtime/src/context.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ use backtrace;
44
use chrono::Utc;
55
use lambda_runtime_client;
66

7-
use crate::env as lambda_env;
8-
use crate::error::HandlerError;
7+
use crate::{env as lambda_env, error::HandlerError};
98

109
/// The Lambda function execution context. The values in this struct
1110
/// are populated using the [Lambda environment variables](https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html)

lambda-runtime/src/env.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ impl ConfigProvider for EnvConfigProvider {
8888

8989
#[cfg(test)]
9090
pub(crate) mod tests {
91-
use crate::env::*;
92-
use crate::error;
91+
use crate::{env::*, error};
9392
use std::{env, error::Error};
9493

9594
pub(crate) struct MockConfigProvider {

lambda-runtime/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,4 @@ mod env;
8383
pub mod error;
8484
mod runtime;
8585

86-
pub use crate::context::*;
87-
pub use crate::error::HandlerError;
88-
pub use crate::runtime::*;
86+
pub use crate::{context::*, error::HandlerError, runtime::*};

lambda-runtime/src/runtime.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ use serde;
55
use serde_json;
66
use tokio::runtime::Runtime as TokioRuntime;
77

8-
use crate::context::Context;
9-
use crate::env::{ConfigProvider, EnvConfigProvider, FunctionSettings};
10-
use crate::error::{HandlerError, RuntimeError};
8+
use crate::{
9+
context::Context,
10+
env::{ConfigProvider, EnvConfigProvider, FunctionSettings},
11+
error::{HandlerError, RuntimeError},
12+
};
1113

1214
const MAX_RETRIES: i8 = 3;
1315

@@ -323,8 +325,7 @@ where
323325
#[cfg(test)]
324326
pub(crate) mod tests {
325327
use super::*;
326-
use crate::context;
327-
use crate::env;
328+
use crate::{context, env};
328329
use lambda_runtime_client::RuntimeClient;
329330

330331
#[test]

0 commit comments

Comments
 (0)