Use identifiers in format!
This commit is contained in:
@@ -20,7 +20,7 @@ fn print_source(lines: &[String], pos: Position, offset: usize, window: (usize,
|
||||
let line = pos.line().unwrap() - 1;
|
||||
let start = if line >= window.0 { line - window.0 } else { 0 };
|
||||
let end = usize::min(line + window.1, lines.len() - 1);
|
||||
let line_no_len = format!("{}", end).len();
|
||||
let line_no_len = end.to_string().len();
|
||||
|
||||
// Print error position
|
||||
if start >= end {
|
||||
|
@@ -260,7 +260,7 @@ mod sample_functions {
|
||||
/// print(result); // prints "42 123"
|
||||
/// ```
|
||||
pub fn test(x: INT, y: INT) -> String {
|
||||
format!("{} {}", x, y)
|
||||
format!("{x} {y}")
|
||||
}
|
||||
|
||||
/// This is a sample method for integers.
|
||||
|
@@ -5,7 +5,7 @@ use std::{env, fs::File, io::Read, path::Path, process::exit};
|
||||
fn eprint_error(input: &str, mut err: EvalAltResult) {
|
||||
fn eprint_line(lines: &[&str], pos: Position, err_msg: &str) {
|
||||
let line = pos.line().unwrap();
|
||||
let line_no = format!("{}: ", line);
|
||||
let line_no = format!("{line}: ");
|
||||
|
||||
eprintln!("{}{}", line_no, lines[line - 1]);
|
||||
eprintln!(
|
||||
|
Reference in New Issue
Block a user