style: update to use rfc2795 formatting (#392)

pull/395/head
Paul Crowley 4 months ago committed by GitHub
parent fbba08333a
commit a4d5ab5692
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -20,7 +20,7 @@ let y = &mut (x.clone());
// without the x.clone() two lines prior, this line would fail on compile as // without the x.clone() two lines prior, this line would fail on compile as
// x has been borrowed // x has been borrowed
// thanks to x.clone(), x was never borrowed, and this line will run. // thanks to x.clone(), x was never borrowed, and this line will run.
println!("{}", x); println!("{x}");
// perform some action on the borrow to prevent rust from optimizing this // perform some action on the borrow to prevent rust from optimizing this
//out of existence //out of existence

@ -278,7 +278,7 @@ Or do they?
fn main() { fn main() {
let a = TestStruct { a: 5, b: "hello".to_string() }; let a = TestStruct { a: 5, b: "hello".to_string() };
let a_data = a.serialize().to_json(); let a_data = a.serialize().to_json();
println!("Our Test Struct as JSON: {}", a_data); println!("Our Test Struct as JSON: {a_data}");
let b = TestStruct::deserialize( let b = TestStruct::deserialize(
generated_visitor_for!(TestStruct)::from_json(a_data)); generated_visitor_for!(TestStruct)::from_json(a_data));
} }

@ -12,7 +12,7 @@ let mut sum = 0;
for i in 1..11 { for i in 1..11 {
sum += i; sum += i;
} }
println!("{}", sum); println!("{sum}");
``` ```
With imperative programs, we have to play compiler to see what is happening. With imperative programs, we have to play compiler to see what is happening.

@ -111,7 +111,7 @@ fn main() {
"Once upon a time, there was a friendly curious crab named Ferris".to_string(); "Once upon a time, there was a friendly curious crab named Ferris".to_string();
for word in sentence_string.split(' ') { for word in sentence_string.split(' ') {
if three_vowels(word) { if three_vowels(word) {
println!("{} has three consecutive vowels!", word); println!("{word} has three consecutive vowels!");
} }
} }
} }

@ -18,7 +18,7 @@ fn say_hello(name: &str) -> String {
// result // result
// But using format! is better. // But using format! is better.
format!("Hello {}!", name) format!("Hello {name}!")
} }
``` ```

@ -44,7 +44,7 @@ fn main() {
let mut conf = MyConfiguration::default(); let mut conf = MyConfiguration::default();
// do something with conf here // do something with conf here
conf.check = true; conf.check = true;
println!("conf = {:#?}", conf); println!("conf = {conf:#?}");
// partial initialization with default values, creates the same instance // partial initialization with default values, creates the same instance
let conf1 = MyConfiguration { let conf1 = MyConfiguration {

@ -71,7 +71,7 @@ pub mod c_api {
format!("cannot write to read-only database"); format!("cannot write to read-only database");
} }
DatabaseError::IOError(e) => { DatabaseError::IOError(e) => {
format!("I/O Error: {}", e); format!("I/O Error: {e}");
} }
DatabaseError::FileCorrupted(s) => { DatabaseError::FileCorrupted(s) => {
format!("File corrupted, run repair: {}", &s); format!("File corrupted, run repair: {}", &s);

@ -32,7 +32,7 @@ let turing = Some("Turing");
let logicians = vec!["Curry", "Kleene", "Markov"]; let logicians = vec!["Curry", "Kleene", "Markov"];
for logician in logicians.iter().chain(turing.iter()) { for logician in logicians.iter().chain(turing.iter()) {
println!("{} is a logician", logician); println!("{logician} is a logician");
} }
``` ```

@ -36,7 +36,7 @@ fn main() {
false false
}; };
println!("success: {}", success); println!("success: {success}");
} }
``` ```

@ -76,7 +76,7 @@ impl<'a> Interpreter<'a> {
self.term(out); self.term(out);
out.push(op); out.push(op);
} else { } else {
panic!("Unexpected symbol '{}'", op); panic!("Unexpected symbol '{op}'");
} }
} }
} }
@ -84,7 +84,7 @@ impl<'a> Interpreter<'a> {
fn term(&mut self, out: &mut String) { fn term(&mut self, out: &mut String) {
match self.next_char() { match self.next_char() {
Some(ch) if ch.is_digit(10) => out.push(ch), Some(ch) if ch.is_digit(10) => out.push(ch),
Some(ch) => panic!("Unexpected symbol '{}'", ch), Some(ch) => panic!("Unexpected symbol '{ch}'"),
None => panic!("Unexpected end of string"), None => panic!("Unexpected end of string"),
} }
} }

@ -60,7 +60,7 @@ struct Text;
impl Formatter for Text { impl Formatter for Text {
fn format(&self, data: &Data, buf: &mut String) { fn format(&self, data: &Data, buf: &mut String) {
for (k, v) in data { for (k, v) in data {
let entry = format!("{} {}\n", k, v); let entry = format!("{k} {v}\n");
buf.push_str(&entry); buf.push_str(&entry);
} }
} }

@ -70,9 +70,9 @@ struct Database {
fn print_database(connection_str: ConnectionString, fn print_database(connection_str: ConnectionString,
timeout: Timeout, timeout: Timeout,
pool_size: PoolSize) { pool_size: PoolSize) {
println!("Connection string: {:?}", connection_str); println!("Connection string: {connection_str:?}");
println!("Timeout: {:?}", timeout); println!("Timeout: {timeout:?}");
println!("Pool size: {:?}", pool_size); println!("Pool size: {pool_size:?}");
} }
fn main() { fn main() {

Loading…
Cancel
Save