Skip to content

Commit cbbed9e

Browse files
committed
Fix fmt error and add build script
1 parent 600e9ae commit cbbed9e

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

build.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
cargo test --all-features
2+
if ($LASTEXITCODE -ne 0) {
3+
Write-Error "Cargo test failed with exit code $LASTEXITCODE"
4+
exit $LASTEXITCODE
5+
}
6+
7+
cargo fmt --all -- --check
8+
if ($LASTEXITCODE -ne 0) {
9+
Write-Error "Cargo fmt failed with exit code $LASTEXITCODE"
10+
exit $LASTEXITCODE
11+
}
12+
13+
cargo clippy --all --all-features --tests -- -D warnings
14+
if ($LASTEXITCODE -ne 0) {
15+
Write-Error "Cargo clippy failed with exit code $LASTEXITCODE"
16+
exit $LASTEXITCODE
17+
}

src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ pub fn brain_luck(code: &str, input: Vec<u8>) -> Result<Vec<u8>, BrainLuckError>
3939
'+' => memory[mem_ptr] = memory[mem_ptr].wrapping_add(1),
4040
'-' => memory[mem_ptr] = memory[mem_ptr].wrapping_sub(1),
4141
'.' => output.push(memory[mem_ptr]),
42-
',' => {
43-
memory[mem_ptr] = *input
44-
.next()
45-
.ok_or(BrainLuckError::UnexpectedEndOfInput)?
46-
}
42+
',' => memory[mem_ptr] = *input.next().ok_or(BrainLuckError::UnexpectedEndOfInput)?,
4743
'[' => {
4844
if memory[mem_ptr] == 0 {
4945
ins_ptr = matching_closing_bracket_ptr(&insts, ins_ptr, Bracket::LBracket)?;

0 commit comments

Comments
 (0)