fn visit_dirs(
  dir: &Path,
  cb: &Fn(&DirEntry, &GuildChannel),
  channel: GuildChannel,
  ctx: &Context,
) -> io::Result<()> {
  if dir.is_dir() {
    let mut paths: Vec<_> = fs::read_dir(dir).unwrap().map(|r| r.unwrap()).collect();
    paths.sort_by_key(|dir| dir.path());
    for path in paths {
      let file = path.path();
      if file.is_dir() {
        let channel = GUILD.create_channel(
          ctx,
          file.file_name().unwrap().to_str().unwrap(),
          ChannelType::Text,
          None,
        );
        visit_dirs(&file, cb, channel.unwrap(), ctx)?;
      } else {
        cb(&path, &channel);
      }
    }
  }
  Ok(())
}
/// Visit every entry in a directory
/// Create the discord channel to send the message to from the folder name
/// Use `visit_files` as file reader.
Visit every entry in a directory
Create the discord channel to send the message to from the folder name
Use `visit_files` as file reader.
Visit every entry in a directory Create the discord channel to send the message to from the folder name Use ` visit_files ` as file reader .
fn visit_dirs(
  dir: &Path,
  cb: &Fn(&DirEntry, &GuildChannel),
  channel: GuildChannel,
  ctx: &Context,
) -> io::Result<()> {
  if dir.is_dir() {
    let mut paths: Vec<_> = fs::read_dir(dir).unwrap().map(|r| r.unwrap()).collect();
    paths.sort_by_key(|dir| dir.path());
    for path in paths {
      let file = path.path();
      if file.is_dir() {
        let channel = GUILD.create_channel(
          ctx,
          file.file_name().unwrap().to_str().unwrap(),
          ChannelType::Text,
          None,
        );
        visit_dirs(&file, cb, channel.unwrap(), ctx)?;
      } else {
        cb(&path, &channel);
      }
    }
  }
  Ok(())
}
fn visit_dirs ( dir : & Path , cb : & Fn ( & DirEntry , & GuildChannel ) , channel : GuildChannel , ctx : & Context , ) -> io :: Result < ( ) > { if dir . is_dir ( ) { let mut paths : Vec < _ > = fs :: read_dir ( dir ) . unwrap ( ) . map ( | r | r . unwrap ( ) ) . collect ( ) ; paths . sort_by_key ( | dir | dir . path ( ) ) ; for path in paths { let file = path . path ( ) ; if file . is_dir ( ) { let channel = GUILD . create_channel ( ctx , file . file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) , ChannelType :: Text , None , ) ; visit_dirs ( & file , cb , channel . unwrap ( ) , ctx ) ? ; } else { cb ( & path , & channel ) ; } } } Ok ( ( ) ) }
Visit every entry in a directory
Create the discord channel to send the message to from the folder name
Use `visit_files` as file reader.
Visit every entry in a directory Create the discord channel to send the message to from the folder name Use ` visit_files ` as file reader .
dir
&Path
cb
&Fn(&DirEntry, &GuildChannel)
channel
GuildChannel
ctx
&Context
dir
&Path
cb
&Fn(&DirEntry, &GuildChannel)
channel
GuildChannel
ctx
&Context