style: update to use rfc2795 formatting (#392)

pull/395/head
Paul Crowley 3 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
// x has been borrowed
// 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
//out of existence

@ -278,7 +278,7 @@ Or do they?
fn main() {
let a = TestStruct { a: 5, b: "hello".to_string() };
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(
generated_visitor_for!(TestStruct)::from_json(a_data));
}

@ -12,7 +12,7 @@ let mut sum = 0;
for i in 1..11 {
sum += i;
}
println!("{}", sum);
println!("{sum}");
```
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();
for word in sentence_string.split(' ') {
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
// But using format! is better.
format!("Hello {}!", name)
format!("Hello {name}!")
}
```

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

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

@ -32,7 +32,7 @@ let turing = Some("Turing");
let logicians = vec!["Curry", "Kleene", "Markov"];
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
};
println!("success: {}", success);
println!("success: {success}");
}
```

@ -76,7 +76,7 @@ impl<'a> Interpreter<'a> {
self.term(out);
out.push(op);
} else {
panic!("Unexpected symbol '{}'", op);
panic!("Unexpected symbol '{op}'");
}
}
}
@ -84,7 +84,7 @@ impl<'a> Interpreter<'a> {
fn term(&mut self, out: &mut String) {
match self.next_char() {
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"),
}
}
@ -137,7 +137,7 @@ fn main() {
assert_eq!(3f64, norm!(x));
assert_eq!(5f64, norm!(x, y));
assert_eq!(0f64, norm!(0, 0, 0));
assert_eq!(0f64, norm!(0, 0, 0));
assert_eq!(1f64, norm!(0.5, -0.5, 0.5, -0.5));
}
```

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

@ -67,12 +67,12 @@ struct Database {
}
// print_database can then take ConnectionString, Timeout and Poolsize struct instead
fn print_database(connection_str: ConnectionString,
timeout: Timeout,
fn print_database(connection_str: ConnectionString,
timeout: Timeout,
pool_size: PoolSize) {
println!("Connection string: {:?}", connection_str);
println!("Timeout: {:?}", timeout);
println!("Pool size: {:?}", pool_size);
println!("Connection string: {connection_str:?}");
println!("Timeout: {timeout:?}");
println!("Pool size: {pool_size:?}");
}
fn main() {

Loading…
Cancel
Save