Skip to content

Commit 1857827

Browse files
committed
misc: applied cargo fmt
1 parent 15d9269 commit 1857827

File tree

11 files changed

+106
-34
lines changed

11 files changed

+106
-34
lines changed

bmatcher-core/src/compiler/error.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use core::{fmt::Debug, ops::Range};
1+
use core::{
2+
fmt::Debug,
3+
ops::Range,
4+
};
25

36
/// A PositionedError representing an error that is associated with a specific position in the given pattern.
47
#[derive(Debug, PartialEq)]

bmatcher-core/src/compiler/lexer.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
use core::ops::Range;
2-
use core::str::CharIndices;
1+
use core::{
2+
ops::Range,
3+
str::CharIndices,
4+
};
35

46
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
57
pub enum Token<'a> {
@@ -187,7 +189,10 @@ impl<'a> Lexer<'a> {
187189
mod test {
188190
use std::iter;
189191

190-
use super::{Lexer, Token};
192+
use super::{
193+
Lexer,
194+
Token,
195+
};
191196

192197
fn execut_tests(test_cases: &[(&str, &[Token<'_>])]) {
193198
for (input, expected_output) in test_cases {

bmatcher-core/src/compiler/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@ mod error;
22
pub use error::PositionedError;
33

44
mod lexer;
5-
use lexer::{Lexer, Token};
5+
use lexer::{
6+
Lexer,
7+
Token,
8+
};
69

710
mod parser;
8-
pub use parser::{parse_pattern, ParseError};
11+
pub use parser::{
12+
parse_pattern,
13+
ParseError,
14+
};
915

1016
mod optimizer;
1117
pub use optimizer::optimize_pattern;

bmatcher-core/src/compiler/optimizer.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use alloc::vec::Vec;
22

33
use crate::{
4-
pattern::{BinaryPattern, OwnedBinaryPattern},
4+
pattern::{
5+
BinaryPattern,
6+
OwnedBinaryPattern,
7+
},
58
Atom,
69
};
710

@@ -235,8 +238,13 @@ pub fn optimize_pattern(pattern: &dyn BinaryPattern) -> OwnedBinaryPattern {
235238

236239
#[cfg(test)]
237240
mod test {
238-
use crate::pattern::BinaryPattern;
239-
use crate::{pattern::OwnedBinaryPattern, Atom};
241+
use crate::{
242+
pattern::{
243+
BinaryPattern,
244+
OwnedBinaryPattern,
245+
},
246+
Atom,
247+
};
240248

241249
fn test_optimize(input: &[Atom], expected: &[Atom]) {
242250
println!("Testing: {:?}", input);

bmatcher-core/src/compiler/parser.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
use core::num::ParseIntError;
2-
31
use alloc::vec::Vec;
2+
use core::num::ParseIntError;
43

5-
use crate::{pattern::OwnedBinaryPattern, Atom, JumpType, ReadWidth};
6-
7-
use super::{Lexer, PositionedError, Token};
4+
use super::{
5+
Lexer,
6+
PositionedError,
7+
Token,
8+
};
9+
use crate::{
10+
pattern::OwnedBinaryPattern,
11+
Atom,
12+
JumpType,
13+
ReadWidth,
14+
};
815

916
#[derive(Debug, PartialEq, Eq, Clone)]
1017
pub enum ParseError {
@@ -363,14 +370,17 @@ pub fn parse_pattern(pattern: &str) -> Result<OwnedBinaryPattern, PositionedErro
363370

364371
#[cfg(test)]
365372
mod test {
373+
use super::PatternParser;
366374
use crate::{
367-
compiler::{parser::ParseError, PositionedError},
368-
Atom, JumpType,
375+
compiler::{
376+
parser::ParseError,
377+
PositionedError,
378+
},
379+
pattern::BinaryPattern,
380+
Atom,
381+
JumpType,
369382
};
370383

371-
use super::PatternParser;
372-
use crate::pattern::BinaryPattern;
373-
374384
#[test]
375385
fn test_byte_sequence() {
376386
{

bmatcher-core/src/lib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ extern crate alloc;
44
pub mod compiler;
55

66
mod atom;
7-
pub use atom::{Atom, JumpType, ReadWidth};
7+
pub use atom::{
8+
Atom,
9+
JumpType,
10+
ReadWidth,
11+
};
812

913
mod target;
1014
pub use target::MatchTarget;
@@ -13,4 +17,8 @@ mod matcher;
1317
pub use matcher::BinaryMatcher;
1418

1519
mod pattern;
16-
pub use pattern::{BinaryPattern, BorrowedBinaryPattern, OwnedBinaryPattern};
20+
pub use pattern::{
21+
BinaryPattern,
22+
BorrowedBinaryPattern,
23+
OwnedBinaryPattern,
24+
};

bmatcher-core/src/matcher.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
use alloc::vec;
2-
use alloc::vec::Vec;
3-
4-
use crate::{Atom, BinaryPattern, JumpType, MatchTarget, ReadWidth};
1+
use alloc::{
2+
vec,
3+
vec::Vec,
4+
};
5+
6+
use crate::{
7+
Atom,
8+
BinaryPattern,
9+
JumpType,
10+
MatchTarget,
11+
ReadWidth,
12+
};
513

614
/// The `BinaryMatcher` is responsible for searching a [BinaryPattern] within a [MatchTarget].
715
///
@@ -190,9 +198,11 @@ impl<'a> BinaryMatcher<'a> {
190198

191199
#[cfg(test)]
192200
mod test {
193-
use crate::{compiler::parse_pattern, BinaryPattern};
194-
195201
use super::BinaryMatcher;
202+
use crate::{
203+
compiler::parse_pattern,
204+
BinaryPattern,
205+
};
196206

197207
const DATA: &[u8] = &[
198208
0xCA, 0x70, 0x11, 0xB5, 0xA, 0x9D, 0x91, 0x83, 0xC4, 0x5A, 0xFC, 0xC7, 0x31, 0x26, 0xC3,

bmatcher-core/src/pattern.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use core::fmt::Debug;
2-
31
use alloc::vec::Vec;
2+
use core::fmt::Debug;
43

54
use crate::Atom;
65

bmatcher-proc/src/macro_pattern.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1-
use std::io::{self, Cursor, Write};
2-
3-
use bmatcher_core::{compiler, Atom, BinaryPattern, JumpType, ReadWidth};
1+
use std::io::{
2+
self,
3+
Cursor,
4+
Write,
5+
};
6+
7+
use bmatcher_core::{
8+
compiler,
9+
Atom,
10+
BinaryPattern,
11+
JumpType,
12+
ReadWidth,
13+
};
414
use proc_macro2::TokenStream;
515
use quote::ToTokens;
6-
use syn::{parse2, Error, Expr, LitStr, Result};
16+
use syn::{
17+
parse2,
18+
Error,
19+
Expr,
20+
LitStr,
21+
Result,
22+
};
723

824
fn emit_atom(output: &mut dyn Write, atom: &Atom) -> io::Result<()> {
925
match atom {

example/src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use bmatcher::{pattern, BinaryMatcher};
1+
use bmatcher::{
2+
pattern,
3+
BinaryMatcher,
4+
};
25

36
fn main() {
47
let data: &[u8] = &[0xE8, 0x00, 0x00, 0x00, 0x00, 0x48, 0x89, 0x04, 0x24, 0xE9];

0 commit comments

Comments
 (0)