# HG changeset patch # User Emmanuel Gil Peyrot # Date 1578347289 -3600 # Node ID 8d29dac12219c2af675dd52e0eae11d9d6499c5e # Parent 01915da33b99a6e7c893ab30a2d8f683f605bd56 examples: Make the common functions take AsRef. diff --git a/examples/common.rs b/examples/common.rs --- a/examples/common.rs +++ b/examples/common.rs @@ -7,7 +7,7 @@ use std::fs::File; use std::io::{BufReader, Read}; use std::path::Path; -pub fn load_file_into_vec(filename: &Path) -> Vec { +pub fn load_file_into_vec>(filename: P) -> Vec { let file = File::open(filename).unwrap(); let mut file = BufReader::new(file); let mut buf = vec![]; @@ -96,7 +96,8 @@ fn load_rgb_a_pngs(surface: &mut GlfwSur } } -pub fn load_anm_image(mut surface: &mut GlfwSurface, anm0: &Anm0, anm_filename: &Path) -> Result { +pub fn load_anm_image>(mut surface: &mut GlfwSurface, anm0: &Anm0, anm_filename: P) -> Result { + let anm_filename = anm_filename.as_ref(); let png_filename = anm_filename.with_file_name(Path::new(&anm0.png_filename).file_name().unwrap()); match anm0.alpha_filename { Some(ref filename) => {