Skip to content

Commit 15857a2

Browse files
committed
clippy fixes
1 parent ce02277 commit 15857a2

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

embeddings/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ fn main() -> Result<()> {
139139
for token in token_line {
140140
// Attempt to convert token to string and print it; if it fails, print the token instead
141141
match model.token_to_str(*token, Special::Tokenize) {
142-
Ok(token_str) => eprintln!(" {} --> {}", token, token_str),
142+
Ok(token_str) => eprintln!("{token} --> {token_str}"),
143143
Err(e) => {
144-
eprintln!("Failed to convert token to string, error: {}", e);
145-
eprintln!("Token value: {}", token);
144+
eprintln!("Failed to convert token to string, error: {e}");
145+
eprintln!("Token value: {token}");
146146
}
147147
}
148148
}

llama-cpp-2/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<'model> LlamaContext<'model> {
7676

7777
match NonZeroI32::new(result) {
7878
None => {
79-
self.initialized_logits = batch.initialized_logits.clone();
79+
self.initialized_logits.clone_from(&batch.initialized_logits);
8080
Ok(())
8181
}
8282
Some(error) => Err(DecodeError::from(error)),

llama-cpp-2/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ pub enum StringToTokenError {
203203
#[error("{0}")]
204204
NulError(#[from] NulError),
205205
#[error("{0}")]
206-
/// Failed to convert a provided integer to a c_int.
206+
/// Failed to convert a provided integer to a [`c_int`].
207207
CIntConversionError(#[from] std::num::TryFromIntError),
208208
}
209209

llama-cpp-2/src/model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ impl LlamaModel {
476476
// Set the tmpl pointer
477477
let tmpl = tmpl.map(CString::new);
478478
let tmpl_ptr = match &tmpl {
479-
Some(str) => str.as_ref().map_err(|e| e.clone())?.as_ptr(),
479+
Some(str) => str.as_ref().map_err(Clone::clone)?.as_ptr(),
480480
None => std::ptr::null(),
481481
};
482482

llama-cpp-sys-2/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ fn compile_metal(cx: &mut Build, cxx: &mut Build) {
555555
// Create a static library for our metal embed code.
556556
let ggml_metal_embed_library_path = PathBuf::from(&out_dir).join("libggml-metal-embed.a");
557557
Command::new("ar")
558-
.args(&[
558+
.args([
559559
"crus",
560560
ggml_metal_embed_library_path.to_str().unwrap(),
561561
ggml_metal_embed_object_path.to_str().unwrap(),

simple/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ impl Model {
117117
}
118118
}
119119

120+
#[allow(clippy::too_many_lines)]
120121
fn main() -> Result<()> {
121122
let Args {
122123
n_len,
@@ -263,7 +264,7 @@ either reduce n_len or increase n_ctx"
263264
// use `Decoder.decode_to_string()` to avoid the intermediate buffer
264265
let mut output_string = String::with_capacity(32);
265266
let _decode_result = decoder.decode_to_string(&output_bytes, &mut output_string, false);
266-
print!("{}", output_string);
267+
print!("{output_string}");
267268
std::io::stdout().flush()?;
268269

269270
batch.clear();

0 commit comments

Comments
 (0)