Skip to content

Commit abe5753

Browse files
committed
rustfmt everything except generated code
I personally disagree with several of rustfmt's decisions, but it's better to be consistent. Generated code isn't being formatted because 1) it would have to get reformatted every time it gets generated; I'm not going to make the generator emit it so it matches rustfmt 2) rustfmt currently chokes on some of the generated code
1 parent 7ad219f commit abe5753

18 files changed

+503
-341
lines changed

.github/workflows/cargo-test.yml

+17-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@ jobs:
1212
with:
1313
submodules: true
1414

15+
- name: Install nightly toolchain
16+
run: |
17+
rustup install nightly --profile minimal
18+
rustup component add clippy --toolchain nightly
19+
rustup component add rustfmt --toolchain nightly
20+
21+
- name: Run rustfmt
22+
# Delete the generated code so it doesn't get formatted.
23+
# We'll be re-running the generator later, so this is okay.
24+
run: |
25+
rm -rf src/generated
26+
echo "// empty module for rustfmt" > src/generated.rs
27+
echo "// empty module for rustfmt" > tests/generated.rs
28+
rustup run nightly cargo fmt --check
29+
rm src/generated.rs
30+
rm tests/generated.rs
31+
1532
- name: Set up Python
1633
uses: actions/[email protected]
1734
with:
@@ -34,11 +51,6 @@ jobs:
3451
- name: Run cargo test
3552
run: rustup run 1.75.0 cargo test --all-features
3653

37-
- name: Install nightly toolchain
38-
run: |
39-
rustup install nightly --profile minimal
40-
rustup component add clippy --toolchain nightly
41-
4254
- name: Run clippy
4355
run: rustup run nightly cargo clippy --all-targets --all-features -- --deny warnings
4456

examples/demo-async.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
//! This example illustrates a few basic Dropbox API operations: getting an OAuth2 token, listing
44
//! the contents of a folder recursively, and fetching a file given its path.
55
6-
use tokio_util::compat::FuturesAsyncReadCompatExt;
7-
use dropbox_sdk::default_async_client::{NoauthDefaultClient, UserAuthDefaultClient};
86
use dropbox_sdk::async_routes::files;
7+
use dropbox_sdk::default_async_client::{NoauthDefaultClient, UserAuthDefaultClient};
8+
use tokio_util::compat::FuturesAsyncReadCompatExt;
99

1010
enum Operation {
1111
Usage,
@@ -68,7 +68,9 @@ async fn main() {
6868

6969
let mut auth = dropbox_sdk::oauth2::get_auth_from_env_or_prompt();
7070
if auth.save().is_none() {
71-
auth.obtain_access_token_async(NoauthDefaultClient::default()).await.unwrap();
71+
auth.obtain_access_token_async(NoauthDefaultClient::default())
72+
.await
73+
.unwrap();
7274
eprintln!("Next time set these environment variables to reuse this authorization:");
7375
eprintln!(" DBX_CLIENT_ID={}", auth.client_id());
7476
eprintln!(" DBX_OAUTH={}", auth.save().unwrap());
@@ -84,10 +86,11 @@ async fn main() {
8486
match files::download(&client, &files::DownloadArg::new(path), None, None).await {
8587
Ok(result) => {
8688
match tokio::io::copy(
87-
&mut result.body.expect("there must be a response body")
88-
.compat(),
89+
&mut result.body.expect("there must be a response body").compat(),
8990
&mut tokio::io::stdout(),
90-
).await {
91+
)
92+
.await
93+
{
9194
Ok(n) => {
9295
eprintln!("Downloaded {n} bytes");
9396
}
@@ -112,7 +115,9 @@ async fn main() {
112115
let mut result = match files::list_folder(
113116
&client,
114117
&files::ListFolderArg::new(path).with_recursive(true),
115-
).await {
118+
)
119+
.await
120+
{
116121
Ok(result) => result,
117122
Err(e) => {
118123
eprintln!("Error from files/list_folder: {e}");
@@ -145,7 +150,9 @@ async fn main() {
145150
result = match files::list_folder_continue(
146151
&client,
147152
&files::ListFolderContinueArg::new(result.cursor),
148-
).await {
153+
)
154+
.await
155+
{
149156
Ok(result) => {
150157
num_pages += 1;
151158
num_entries += result.entries.len();

examples/demo.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ fn main() {
6868

6969
let mut auth = dropbox_sdk::oauth2::get_auth_from_env_or_prompt();
7070
if auth.save().is_none() {
71-
auth.obtain_access_token(NoauthDefaultClient::default()).unwrap();
71+
auth.obtain_access_token(NoauthDefaultClient::default())
72+
.unwrap();
7273
eprintln!("Next time set these environment variables to reuse this authorization:");
7374
eprintln!(" DBX_CLIENT_ID={}", auth.client_id());
7475
eprintln!(" DBX_OAUTH={}", auth.save().unwrap());

0 commit comments

Comments
 (0)