Skip to content

Commit

Permalink
Use u8 for tab
Browse files Browse the repository at this point in the history
  • Loading branch information
WGUNDERWOOD committed Oct 16, 2024
1 parent e9f11fe commit 0179f12
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct Cli {
help = "Number of spaces to use as tab size",
default_value_t = 2
)]
pub tab: i8,
pub tab: u8,
#[arg(long, help = "Use tabs instead of spaces for indentation")]
pub usetabs: bool,
#[arg(long, help = "Line length for wrapping", default_value_t = 80)]
Expand Down
2 changes: 1 addition & 1 deletion src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn format_file(
&pattern,
);

let indent_length = usize::try_from(indent.visual * args.tab)
let indent_length = usize::try_from(indent.visual * args.tab as i8)
.expect("Visual indent is non-negative.");

// Wrap the line before applying the indent, and loop back
Expand Down
2 changes: 1 addition & 1 deletion src/indent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pub fn apply_indent(
// Otherwise, allocate enough memory to fit line with the added
// indentation and insert the appropriate string slices
} else {
let n_indent_chars = usize::try_from(indent.visual * args.tab).unwrap();
let n_indent_chars = usize::try_from(indent.visual * args.tab as i8).unwrap();
let mut new_line =
String::with_capacity(trimmed_line.len() + n_indent_chars);
for idx in 0..n_indent_chars {
Expand Down

0 comments on commit 0179f12

Please sign in to comment.