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	Mon Jan 06 22:43:31 2020 +0100
+++ b/examples/common.rs	Mon Jan 06 22:48:09 2020 +0100
@@ -7,7 +7,7 @@
 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 @@
     }
 }
 
-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) => {