nrc / graphql

A Rust GraphQL server framework
Apache License 2.0
236 stars 12 forks source link

Format Code #25

Closed scrogson closed 6 years ago

scrogson commented 6 years ago

This PR is to address #17.

I noticed a failing test, so I took care of that while I was at it.

When I ran cargo fmt I noticed these errors:

error: line exceeded maximum width (maximum: 100, found: 108)
   --> /home/scrogson/github/nrc/graphql/graphql-macros/src/lib.rs:209
    |
209 |                     _ => return Err(QlError::LoweringError(format!("{:?}", value), $expect_str.to_owned())),
    |                                                                                                     ^^^^^^^^
error: line exceeded maximum width (maximum: 100, found: 132)
   --> /home/scrogson/github/nrc/graphql/graphql-macros/src/lib.rs:423
    |
423 |                                 n => return Err(QlError::ExecutionError(format!("Missing field executor in {}: {}", $name_str, n))),
    |                                                                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: line exceeded maximum width (maximum: 100, found: 102)
   --> /home/scrogson/github/nrc/graphql/graphql-macros/src/lib.rs:454
    |
454 |                         _ => return Err(QlError::ResolveError("field", field.name.to_string(), None)),
    |                                                                                                     ^^
error: line exceeded maximum width (maximum: 100, found: 102)
   --> /home/scrogson/github/nrc/graphql/graphql-macros/src/lib.rs:533
    |
533 |                                     // This is a special case where the result doesn't match the query
    |                                                                                                     ^^
error: line exceeded maximum width (maximum: 100, found: 110)
   --> /home/scrogson/github/nrc/graphql/graphql-macros/src/lib.rs:590
    |
590 |             quote!($name_str => result.push((types::Name($name_str.to_owned()), self.resolve_field(field)?)),)
    |                                                                                                     ^^^^^^^^^^
warning: rustfmt may have failed to format. See previous 5 errors.

Unfortunately, I'm not sure how I should go about fixing those idiomatically.

nrc commented 6 years ago

Nice, thank you! For the first three line width issues the re-formatting should look something like:

                    _ => {
                        return Err(QlError::LoweringError(
                            format!("{:?}", value),
                            $expect_str.to_owned(),
                        ))
                    }

The comment just needs splitting into a two line comment. The quote line should follow the above one, but there should be newlines after the opening ( and before the ) too, look at the other mulit-line uses of quote in that file.

scrogson commented 6 years ago

Ok, all fixed up.

nrc commented 6 years ago

Thank you!