Mercurial > touhou
changeset 740:8d29dac12219
examples: Make the common functions take AsRef<Path>.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Mon, 06 Jan 2020 22:48:09 +0100 |
parents | 01915da33b99 |
children | 3555845f8cf4 |
files | examples/common.rs |
diffstat | 1 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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<u8> { +pub fn load_file_into_vec<P: AsRef<Path>>(filename: P) -> Vec<u8> { 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<LoadedTexture, TextureLoadError> { +pub fn load_anm_image<P: AsRef<Path>>(mut surface: &mut GlfwSurface, anm0: &Anm0, anm_filename: P) -> Result<LoadedTexture, TextureLoadError> { + 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) => {