Skip to content
This repository was archived by the owner on Oct 17, 2024. It is now read-only.

Commit 7c38d1d

Browse files
authored
chore: minor cleanup (#32)
* chore: minor cleanup Signed-off-by: Henry Schreiner <[email protected]> * Update table.rs --------- Signed-off-by: Henry Schreiner <[email protected]>
1 parent 0eee83a commit 7c38d1d

File tree

6 files changed

+10
-9
lines changed

6 files changed

+10
-9
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ dist
1010
/src/pyproject_fmt_rust/_lib.abi3*
1111
/tarpaulin-report.html
1212
/build_rs_cov.profraw
13+
/.cargo/config.toml

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/src/build_system.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::helpers::pep508::{format_requirement, get_canonic_requirement_name};
33
use crate::helpers::table::{for_entries, reorder_table_keys, Tables};
44

55
pub fn fix(tables: &mut Tables, keep_full_version: bool) {
6-
let table_element = tables.get(&String::from("build-system"));
6+
let table_element = tables.get("build-system");
77
if table_element.is_none() {
88
return;
99
}

rust/src/helpers/table.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ pub fn reorder_table_keys(table: &mut RefMut<Vec<SyntaxElement>>, order: &[&str]
186186
table.splice(0..size, to_insert);
187187
}
188188

189-
fn load_keys(table: &RefMut<Vec<SyntaxElement>>) -> (HashMap<String, usize>, Vec<Vec<SyntaxElement>>) {
189+
fn load_keys(table: &[SyntaxElement]) -> (HashMap<String, usize>, Vec<Vec<SyntaxElement>>) {
190190
let mut key_to_pos = HashMap::<String, usize>::new();
191191
let mut key_set = Vec::<Vec<SyntaxElement>>::new();
192192
let entry_set = RefCell::new(Vec::<SyntaxElement>::new());
@@ -200,7 +200,7 @@ fn load_keys(table: &RefMut<Vec<SyntaxElement>>) -> (HashMap<String, usize>, Vec
200200
};
201201
let mut key = String::new();
202202
let mut cutoff = false;
203-
for element in table.iter() {
203+
for element in table {
204204
let kind = element.kind();
205205
if kind == ENTRY {
206206
if cutoff {
@@ -238,12 +238,12 @@ pub fn get_table_name(entry: &SyntaxElement) -> String {
238238
String::new()
239239
}
240240

241-
pub fn for_entries<F>(table: &RefMut<Vec<SyntaxElement>>, f: &mut F)
241+
pub fn for_entries<F>(table: &[SyntaxElement], f: &mut F)
242242
where
243243
F: FnMut(String, &SyntaxNode),
244244
{
245245
let mut key = String::new();
246-
for table_entry in table.iter() {
246+
for table_entry in table {
247247
if table_entry.kind() == ENTRY {
248248
for entry in table_entry.as_node().unwrap().children_with_tokens() {
249249
if entry.kind() == KEY {

rust/src/project.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn fix(
2121
min_supported_python: (u8, u8),
2222
) {
2323
collapse_sub_tables(tables, "project");
24-
let table_element = tables.get(&String::from("project"));
24+
let table_element = tables.get("project");
2525
if table_element.is_none() {
2626
return;
2727
}
@@ -291,7 +291,7 @@ fn generate_classifiers_to_entry(
291291
type MaxMinPythonWithClassifier = ((u8, u8), (u8, u8), Vec<u8>, Option<HashSet<String>>);
292292

293293
fn get_python_requires_with_classifier(
294-
table: &RefMut<Vec<SyntaxElement>>,
294+
table: &[SyntaxElement],
295295
max_supported_python: (u8, u8),
296296
min_supported_python: (u8, u8),
297297
) -> MaxMinPythonWithClassifier {

rust/src/ruff.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::helpers::table::{collapse_sub_tables, for_entries, reorder_table_keys
55
#[allow(clippy::too_many_lines)]
66
pub fn fix(tables: &mut Tables) {
77
collapse_sub_tables(tables, "tool.ruff");
8-
let table_element = tables.get(&String::from("tool.ruff"));
8+
let table_element = tables.get("tool.ruff");
99
if table_element.is_none() {
1010
return;
1111
}

0 commit comments

Comments
 (0)