Skip to content

Commit

Permalink
refactor: simplify lifetime annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
sepcnt committed Dec 25, 2024
1 parent fda27d2 commit 9274651
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 4 additions & 2 deletions jieba-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ pub fn generate_hmm_data(_input: TokenStream) -> TokenStream {
let mut lines = hmm_data.lines().skip_while(|x| x.starts_with('#'));

// Initial probabilities
let init_probs = lines.next().expect("Failed to read initial probabilities from hmm.model");

let init_probs = lines
.next()
.expect("Failed to read initial probabilities from hmm.model");

output.push_str("#[allow(clippy::style)]\n");
output.push_str("pub static INITIAL_PROBS: [f64; 4] = [");
output.push_str(&init_probs.replace(' ', ", "));
Expand Down
2 changes: 0 additions & 2 deletions src/hmm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ lazy_static! {

pub const NUM_STATES: usize = 4;

pub type StateSet = [f64; NUM_STATES];

/// Result of hmm is a labeling of each Unicode Scalar Value in the input
/// string with Begin, Middle, End, or Single. These denote the proposed
/// segments. A segment is one of the following two patterns.
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl<'t> SplitState<'t> {
}
}

impl<'r, 't> Iterator for SplitMatches<'r, 't> {
impl<'t> Iterator for SplitMatches<'_, 't> {
type Item = SplitState<'t>;

fn next(&mut self) -> Option<SplitState<'t>> {
Expand Down Expand Up @@ -768,7 +768,7 @@ impl Jieba {
/// `sentence`: input text
///
/// `hmm`: enable HMM or not
pub fn tag<'a>(&'a self, sentence: &'a str, hmm: bool) -> Vec<Tag> {
pub fn tag<'a>(&'a self, sentence: &'a str, hmm: bool) -> Vec<Tag<'a>> {
let words = self.cut(sentence, hmm);
words
.into_iter()
Expand Down
2 changes: 1 addition & 1 deletion src/sparse_dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct EdgeIter<'a> {
cursor: usize,
}

impl<'a> Iterator for EdgeIter<'a> {
impl Iterator for EdgeIter<'_> {
type Item = usize;

fn size_hint(&self) -> (usize, Option<usize>) {
Expand Down

0 comments on commit 9274651

Please sign in to comment.