From 3767677b9d5efe1f7c7ba9e9aca5ef783bd5cc35 Mon Sep 17 00:00:00 2001 From: llogiq Date: Fri, 8 Apr 2016 23:32:24 +0200 Subject: [PATCH] Fixed some clippy warnings. Closes #4 --- src/lib/custom_error.rs | 8 ++++---- src/lib/gf256.rs | 2 +- src/lib/mod.rs | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/custom_error.rs b/src/lib/custom_error.rs index 80db414..6d090db 100644 --- a/src/lib/custom_error.rs +++ b/src/lib/custom_error.rs @@ -6,7 +6,7 @@ use std::fmt; use std::io; use std::num; -/// Error struct used for generating an io:Error from a generic description. +/// Error struct used for generating an `io::Error` from a generic description. #[derive(Debug)] pub struct Error { descr: &'static str, @@ -39,15 +39,15 @@ impl convert::From for io::Error { } } -/// Returns an io:Error from description string and optional detail string. -/// Particularly useful in Result expressions. +/// Returns an `io::Error` from description string and optional detail string. +/// Particularly useful in `Result` expressions. pub fn other_io_err(descr: &'static str, detail: Option) -> io::Error { convert::From::from( Error::new(descr, detail) ) } -/// maps a ParseIntError to an io::Error +/// maps a `ParseIntError` to an `io::Error` pub fn pie2io(p: num::ParseIntError) -> io::Error { convert::From::from( Error::new("Integer parsing error", Some(p.to_string())) diff --git a/src/lib/gf256.rs b/src/lib/gf256.rs index b151c0c..ccb66ae 100644 --- a/src/lib/gf256.rs +++ b/src/lib/gf256.rs @@ -6,7 +6,7 @@ use std::ops::{ Add, Sub, Mul, Div }; include!(concat!(env!("OUT_DIR"), "/nothinghardcoded.rs")); fn get_tables() -> &'static Tables { - return &TABLES; + &TABLES } /// Type for elements of a finite field with 256 elements diff --git a/src/lib/mod.rs b/src/lib/mod.rs index affa4b7..7cac73c 100644 --- a/src/lib/mod.rs +++ b/src/lib/mod.rs @@ -10,7 +10,7 @@ use self::gf256::Gf256; use std::io; use std::iter::repeat; -/// Generate generic errors that typeset with io::Error. +/// Generate generic errors that typeset with `io::Error`. pub mod custom_error; use self::custom_error::*; @@ -31,7 +31,7 @@ use self::custom_error::*; /// } /// ``` -pub fn generate_shares(k: u8, n: u8, secret: &Vec) -> io::Result> { +pub fn generate_shares(k: u8, n: u8, secret: &[u8]) -> io::Result> { if k > n { return Err(other_io_err("Threshold K can not be larger than N", None)); } @@ -53,7 +53,7 @@ pub fn generate_shares(k: u8, n: u8, secret: &Vec) -> io::Result Ok(result) } -fn process_shares(shares_strings: Vec) -> io::Result<(u8, Vec<(u8,Vec)>)> { +fn process_shares(shares_strings: Vec) -> io::Result<(u8, Vec<(u8, Vec)>)> { let mut opt_k_l: Option<(u8, usize)> = None; let mut counter = 0u8; let mut shares: Vec<(u8,Vec)> = Vec::new(); @@ -137,7 +137,7 @@ pub fn recover_secret(shares: Vec) -> io::Result> { secret.push(lagrange_interpolate(&*col_in, 0u8)); } - return Ok(secret) as io::Result>; + Ok(secret) as io::Result> } fn new_vec(n: usize, x: T) -> Vec {