From e18a1045d83c86da3f4e11a80763008f93253fed Mon Sep 17 00:00:00 2001 From: mh-northlander Date: Fri, 28 Jun 2024 17:42:50 +0900 Subject: [PATCH] take more general arg type (ptr_arg) --- python/src/word_info.rs | 6 +++--- sudachi-cli/src/main.rs | 2 +- sudachi/src/analysis/stateless_tokenizer.rs | 2 +- sudachi/src/dic/build/lexicon.rs | 2 +- sudachi/src/dic/lexicon_set.rs | 2 +- sudachi/src/input_text/buffer/edit.rs | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/python/src/word_info.rs b/python/src/word_info.rs index eb51a28d..50283402 100644 --- a/python/src/word_info.rs +++ b/python/src/word_info.rs @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Works Applications Co., Ltd. + * Copyright (c) 2021-2024 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,9 +33,9 @@ pub struct PyWordInfo { synonym_group_ids: Vec, } -fn copy_if_empty(v1: String, v2: &String) -> String { +fn copy_if_empty(v1: String, v2: &str) -> String { if v1.is_empty() { - v2.clone() + v2.to_owned() } else { v1 } diff --git a/sudachi-cli/src/main.rs b/sudachi-cli/src/main.rs index 0c1a01bc..ceac0791 100644 --- a/sudachi-cli/src/main.rs +++ b/sudachi-cli/src/main.rs @@ -32,7 +32,7 @@ use sudachi::config::Config; use sudachi::dic::dictionary::JapaneseDictionary; use sudachi::prelude::*; -#[derive(Clone, Copy, Debug, Eq, PartialEq)] +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] pub enum SentenceSplitMode { /// Do both sentence splitting and analysis #[default] diff --git a/sudachi/src/analysis/stateless_tokenizer.rs b/sudachi/src/analysis/stateless_tokenizer.rs index 669d7720..eabee275 100644 --- a/sudachi/src/analysis/stateless_tokenizer.rs +++ b/sudachi/src/analysis/stateless_tokenizer.rs @@ -132,7 +132,7 @@ pub(super) fn split_path( Ok(new_path) } -pub(super) fn dump_path(path: &Vec) { +pub(super) fn dump_path(path: &[ResultNode]) { for (i, node) in path.iter().enumerate() { println!("{}: {}", i, node); } diff --git a/sudachi/src/dic/build/lexicon.rs b/sudachi/src/dic/build/lexicon.rs index 49e44963..6514c4e7 100644 --- a/sudachi/src/dic/build/lexicon.rs +++ b/sudachi/src/dic/build/lexicon.rs @@ -84,7 +84,7 @@ impl StrPosEntry { Self { data: owned } } - pub fn from_built_pos(data: &Vec) -> Self { + pub fn from_built_pos(data: &[String]) -> Self { let mut iter = data.iter().map(|x| x.as_str()); let p1 = Cow::Borrowed(iter.next().unwrap()); let p2 = Cow::Borrowed(iter.next().unwrap()); diff --git a/sudachi/src/dic/lexicon_set.rs b/sudachi/src/dic/lexicon_set.rs index 3a00ab68..1f41632b 100644 --- a/sudachi/src/dic/lexicon_set.rs +++ b/sudachi/src/dic/lexicon_set.rs @@ -142,7 +142,7 @@ impl LexiconSet<'_> { self.lexicons[dic_id].get_word_param(id.word()) } - fn update_dict_id(split: &mut Vec, dict_id: u8) -> SudachiResult<()> { + fn update_dict_id(split: &mut [WordId], dict_id: u8) -> SudachiResult<()> { for id in split.iter_mut() { let cur_dict_id = id.dic(); if cur_dict_id > 0 { diff --git a/sudachi/src/input_text/buffer/edit.rs b/sudachi/src/input_text/buffer/edit.rs index 300f73ab..41ac5232 100644 --- a/sudachi/src/input_text/buffer/edit.rs +++ b/sudachi/src/input_text/buffer/edit.rs @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Works Applications Co., Ltd. + * Copyright (c) 2021-2024 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,7 +89,7 @@ impl<'a> InputEditor<'a> { // Current plugin implementations satisfy this criteria. pub fn resolve_edits( source: &str, - source_mapping: &Vec, + source_mapping: &[usize], target: &mut String, target_mapping: &mut Vec, edits: &mut Vec, @@ -127,7 +127,7 @@ pub fn resolve_edits( } fn add_replace( - source_mapping: &Vec, + source_mapping: &[usize], target: &mut String, target_mapping: &mut Vec, what: Range,