1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 04:27:45 +00:00

Add explicit lifetimes

This commit is contained in:
Michael Gehring 2014-08-31 20:01:41 +02:00
parent cdacaaa648
commit 1c8e9161cc
5 changed files with 7 additions and 7 deletions

View file

@ -105,7 +105,7 @@ pub fn uumain(args: Vec<String>) -> int {
return 0;
}
fn open(path: String) -> io::BufferedReader<Box<Reader>> {
fn open(path: String) -> io::BufferedReader<Box<Reader+'static>> {
let mut file_buf;
if path.as_slice() == "-" {
io::BufferedReader::new(box io::stdio::stdin_raw() as Box<Reader>)

View file

@ -59,7 +59,7 @@ fn get_algo_opts(program: &str) -> Vec<getopts::OptGroup> {
}
}
fn detect_algo(program: &str, matches: &getopts::Matches) -> (&'static str, Box<Digest>) {
fn detect_algo(program: &str, matches: &getopts::Matches) -> (&'static str, Box<Digest+'static>) {
let mut alg: Option<Box<Digest>> = None;
let mut name: &'static str = "";
match program {
@ -71,7 +71,7 @@ fn detect_algo(program: &str, matches: &getopts::Matches) -> (&'static str, Box<
"sha512sum" => ("SHA512", box Sha512::new() as Box<Digest>),
_ => {
{
let set_or_crash = |n: &'static str, val: Box<Digest>| -> () {
let set_or_crash = |n, val| -> () {
if alg.is_some() { crash!(1, "You cannot combine multiple hash algorithms!") };
name = n;
alg = Some(val);

View file

@ -107,7 +107,7 @@ pub fn uumain(args: Vec<String>) -> int {
return 0;
}
fn open(path: String) -> io::BufferedReader<Box<Reader>> {
fn open(path: String) -> io::BufferedReader<Box<Reader+'static>> {
let mut file_buf;
if path.as_slice() == "-" {
io::BufferedReader::new(box io::stdio::stdin_raw() as Box<Reader>)

View file

@ -190,7 +190,7 @@ pub fn uumain(args: Vec<String>) -> int {
0
}
fn open_input_file(in_file_name: String) -> io::BufferedReader<Box<Reader>> {
fn open_input_file(in_file_name: String) -> io::BufferedReader<Box<Reader+'static>> {
let in_file = if in_file_name.as_slice() == "-" {
box io::stdio::stdin_raw() as Box<Reader>
} else {
@ -201,7 +201,7 @@ fn open_input_file(in_file_name: String) -> io::BufferedReader<Box<Reader>> {
io::BufferedReader::new(in_file)
}
fn open_output_file(out_file_name: String) -> io::BufferedWriter<Box<Writer>> {
fn open_output_file(out_file_name: String) -> io::BufferedWriter<Box<Writer+'static>> {
let out_file = if out_file_name.as_slice() == "-" {
box io::stdio::stdout_raw() as Box<Writer>
} else {

View file

@ -230,7 +230,7 @@ fn print_stats(filename: &str, line_count: uint, word_count: uint, char_count: u
}
}
fn open(path: String) -> StdResult<BufferedReader<Box<Reader>>, int> {
fn open(path: String) -> StdResult<BufferedReader<Box<Reader+'static>>, int> {
if "-" == path.as_slice() {
let reader = box stdin_raw() as Box<Reader>;
return Ok(BufferedReader::new(reader));