mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-12-22 18:16:30 +00:00
Replace string range access with strip_prefix()
This commit is contained in:
parent
1a24ba44b2
commit
35e71b0f8a
1 changed files with 4 additions and 4 deletions
8
plume-macro/src/lib.rs
Normal file → Executable file
8
plume-macro/src/lib.rs
Normal file → Executable file
|
@ -89,12 +89,12 @@ fn file_to_migration(file: &str) -> TokenStream2 {
|
||||||
let mut actions = vec![];
|
let mut actions = vec![];
|
||||||
for line in file.lines() {
|
for line in file.lines() {
|
||||||
if sql {
|
if sql {
|
||||||
if line.starts_with("--#!") {
|
if let Some(acc_str) = line.strip_prefix("--#!") {
|
||||||
if !acc.trim().is_empty() {
|
if !acc.trim().is_empty() {
|
||||||
actions.push(quote!(Action::Sql(#acc)));
|
actions.push(quote!(Action::Sql(#acc)));
|
||||||
}
|
}
|
||||||
sql = false;
|
sql = false;
|
||||||
acc = line[4..].to_string();
|
acc = acc_str.to_string();
|
||||||
acc.push('\n');
|
acc.push('\n');
|
||||||
} else if line.starts_with("--") {
|
} else if line.starts_with("--") {
|
||||||
continue;
|
continue;
|
||||||
|
@ -102,8 +102,8 @@ fn file_to_migration(file: &str) -> TokenStream2 {
|
||||||
acc.push_str(line);
|
acc.push_str(line);
|
||||||
acc.push('\n');
|
acc.push('\n');
|
||||||
}
|
}
|
||||||
} else if line.starts_with("--#!") {
|
} else if let Some(acc_str) = line.strip_prefix("--#!") {
|
||||||
acc.push_str(&line[4..]);
|
acc.push_str(&acc_str);
|
||||||
acc.push('\n');
|
acc.push('\n');
|
||||||
} else if line.starts_with("--") {
|
} else if line.starts_with("--") {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue