Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
john-parton committed Oct 13, 2023
1 parent 540d72b commit 869408a
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn _fix_encoding_name(encoding: &str) -> &str {
}

#[doc = include_str!("../chardetng_docs/EncodingDetector.md")]
#[pyclass(name="EncodingDetector")]
#[pyclass(name = "EncodingDetector")]
struct EncodingDetectorWrapper {
encoding_detector: EncodingDetector,
}
Expand All @@ -28,7 +28,7 @@ impl EncodingDetectorWrapper {
#[new]
fn new() -> Self {
EncodingDetectorWrapper {
encoding_detector: EncodingDetector::new()
encoding_detector: EncodingDetector::new(),
}
}

Expand All @@ -41,26 +41,18 @@ impl EncodingDetectorWrapper {
#[doc = include_str!("../chardetng_docs/guess.md")]
#[pyo3(signature=(*, tld, allow_utf8))]
fn guess(&self, tld: Option<&[u8]>, allow_utf8: bool) -> &'static str {

_fix_encoding_name(
self.encoding_detector.guess(tld, allow_utf8).name()
)
_fix_encoding_name(self.encoding_detector.guess(tld, allow_utf8).name())
}

#[doc = include_str!("../chardetng_docs/guess_assess.md")]
#[pyo3(signature=(*, tld, allow_utf8))]
fn guess_assess(&self, tld: Option<&[u8]>, allow_utf8: bool) -> (&'static str, bool) {

let (encoding, higher_score) = self.encoding_detector.guess_assess(tld, allow_utf8);

(
_fix_encoding_name(encoding.name()),
higher_score
)
(_fix_encoding_name(encoding.name()), higher_score)
}
}


#[pymodule]
fn detector(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<EncodingDetectorWrapper>()?;
Expand Down

0 comments on commit 869408a

Please sign in to comment.