Add explicit 'dyn's as per Rust nightly requirements

This commit is contained in:
James 2019-06-23 21:35:41 +10:00
parent 4d50a0f8f8
commit 5d53ef7a2e
18 changed files with 28 additions and 28 deletions

View file

@ -16,7 +16,7 @@ pub trait Archive<'a> {
/// func: iterator value, max size, file name, file contents
fn for_each(
&mut self,
func: &mut FnMut(usize, Option<usize>, PathBuf, &mut Read) -> Result<(), String>,
func: &mut dyn FnMut(usize, Option<usize>, PathBuf, &mut dyn Read) -> Result<(), String>,
) -> Result<(), String>;
}
@ -27,7 +27,7 @@ struct ZipArchive<'a> {
impl<'a> Archive<'a> for ZipArchive<'a> {
fn for_each(
&mut self,
func: &mut FnMut(usize, Option<usize>, PathBuf, &mut Read) -> Result<(), String>,
func: &mut dyn FnMut(usize, Option<usize>, PathBuf, &mut dyn Read) -> Result<(), String>,
) -> Result<(), String> {
let max = self.archive.len();
@ -49,13 +49,13 @@ impl<'a> Archive<'a> for ZipArchive<'a> {
}
struct TarArchive<'a> {
archive: UpstreamTarArchive<Box<Read + 'a>>,
archive: UpstreamTarArchive<Box<dyn Read + 'a>>,
}
impl<'a> Archive<'a> for TarArchive<'a> {
fn for_each(
&mut self,
func: &mut FnMut(usize, Option<usize>, PathBuf, &mut Read) -> Result<(), String>,
func: &mut dyn FnMut(usize, Option<usize>, PathBuf, &mut dyn Read) -> Result<(), String>,
) -> Result<(), String> {
let entries = self
.archive
@ -83,7 +83,7 @@ impl<'a> Archive<'a> for TarArchive<'a> {
}
/// Reads the named archive with an archive implementation.
pub fn read_archive<'a>(name: &str, data: &'a [u8]) -> Result<Box<Archive<'a> + 'a>, String> {
pub fn read_archive<'a>(name: &str, data: &'a [u8]) -> Result<Box<dyn Archive<'a> + 'a>, String> {
if name.ends_with(".zip") {
// Decompress a .zip file
let archive = UpstreamZipArchive::new(Cursor::new(data))
@ -98,7 +98,7 @@ pub fn read_archive<'a>(name: &str, data: &'a [u8]) -> Result<Box<Archive<'a> +
.read_to_end(&mut decompressed_data)
.map_err(|x| format!("Failed to decompress data: {:?}", x))?;
let decompressed_contents: Box<Read> = Box::new(Cursor::new(decompressed_data));
let decompressed_contents: Box<dyn Read> = Box::new(Cursor::new(decompressed_data));
let tar = UpstreamTarArchive::new(decompressed_contents);

View file

@ -41,7 +41,7 @@ pub type Response = hyper::server::Response;
pub type Error = hyper::Error;
/// The return type used by function calls to the web server.
pub type Future = Box<futures::Future<Item = Response, Error = Error>>;
pub type Future = Box<dyn futures::Future<Item = Response, Error = Error>>;
/// If advanced functionality is not needed, return a default instant future.
pub fn default_future(response: Response) -> Future {

View file

@ -9,7 +9,7 @@ pub mod github;
use self::types::ReleaseSource;
/// Returns a ReleaseSource by a name, if possible
pub fn get_by_name(name: &str) -> Option<Box<ReleaseSource>> {
pub fn get_by_name(name: &str) -> Option<Box<dyn ReleaseSource>> {
match name {
"github" => Some(Box::new(github::GithubReleases::new())),
_ => None,

View file

@ -25,7 +25,7 @@ impl Task for DownloadPackageTask {
&mut self,
mut input: Vec<TaskParamType>,
context: &mut InstallerFramework,
messenger: &Fn(&TaskMessage),
messenger: &dyn Fn(&TaskMessage),
) -> Result<TaskParamType, String> {
assert_eq!(input.len(), 1);

View file

@ -19,7 +19,7 @@ impl Task for EnsureOnlyInstanceTask {
&mut self,
input: Vec<TaskParamType>,
context: &mut InstallerFramework,
_messenger: &Fn(&TaskMessage),
_messenger: &dyn Fn(&TaskMessage),
) -> Result<TaskParamType, String> {
assert_eq!(input.len(), 0);

View file

@ -26,7 +26,7 @@ impl Task for InstallTask {
&mut self,
_: Vec<TaskParamType>,
_: &mut InstallerFramework,
messenger: &Fn(&TaskMessage),
messenger: &dyn Fn(&TaskMessage),
) -> Result<TaskParamType, String> {
messenger(&TaskMessage::DisplayMessage("Wrapping up...", 0.0));
Ok(TaskParamType::None)

View file

@ -21,7 +21,7 @@ impl Task for VerifyInstallDirTask {
&mut self,
input: Vec<TaskParamType>,
context: &mut InstallerFramework,
messenger: &Fn(&TaskMessage),
messenger: &dyn Fn(&TaskMessage),
) -> Result<TaskParamType, String> {
assert_eq!(input.len(), 0);
messenger(&TaskMessage::DisplayMessage(

View file

@ -20,7 +20,7 @@ impl Task for InstallGlobalShortcutsTask {
&mut self,
_: Vec<TaskParamType>,
context: &mut InstallerFramework,
messenger: &Fn(&TaskMessage),
messenger: &dyn Fn(&TaskMessage),
) -> Result<TaskParamType, String> {
messenger(&TaskMessage::DisplayMessage(
"Generating global shortcut...",

View file

@ -34,7 +34,7 @@ impl Task for InstallPackageTask {
&mut self,
mut input: Vec<TaskParamType>,
context: &mut InstallerFramework,
messenger: &Fn(&TaskMessage),
messenger: &dyn Fn(&TaskMessage),
) -> Result<TaskParamType, String> {
messenger(&TaskMessage::DisplayMessage(
&format!("Installing package {:?}...", self.name),

View file

@ -22,7 +22,7 @@ impl Task for InstallShortcutsTask {
&mut self,
_: Vec<TaskParamType>,
context: &mut InstallerFramework,
messenger: &Fn(&TaskMessage),
messenger: &dyn Fn(&TaskMessage),
) -> Result<TaskParamType, String> {
messenger(&TaskMessage::DisplayMessage(
&format!("Generating shortcuts for package {:?}...", self.name),

View file

@ -49,12 +49,12 @@ pub enum TaskOrdering {
/// A dependency of a task with various properties.
pub struct TaskDependency {
ordering: TaskOrdering,
task: Box<Task>,
task: Box<dyn Task>,
}
impl TaskDependency {
/// Builds a new dependency from the specified task.
pub fn build(ordering: TaskOrdering, task: Box<Task>) -> TaskDependency {
pub fn build(ordering: TaskOrdering, task: Box<dyn Task>) -> TaskDependency {
TaskDependency { ordering, task }
}
}
@ -74,7 +74,7 @@ pub trait Task {
&mut self,
input: Vec<TaskParamType>,
context: &mut InstallerFramework,
messenger: &Fn(&TaskMessage),
messenger: &dyn Fn(&TaskMessage),
) -> Result<TaskParamType, String>;
/// Returns a vector containing all dependencies that need to be executed
@ -87,7 +87,7 @@ pub trait Task {
/// The dependency tree allows for smart iteration on a Task struct.
pub struct DependencyTree {
task: Box<Task>,
task: Box<dyn Task>,
dependencies: Vec<(TaskOrdering, DependencyTree)>,
}
@ -120,7 +120,7 @@ impl DependencyTree {
pub fn execute(
&mut self,
context: &mut InstallerFramework,
messenger: &Fn(&TaskMessage),
messenger: &dyn Fn(&TaskMessage),
) -> Result<TaskParamType, String> {
let total_tasks = (self.dependencies.len() + 1) as f64;
@ -206,7 +206,7 @@ impl DependencyTree {
}
/// Builds a new pipeline from the specified task, iterating on dependencies.
pub fn build(task: Box<Task>) -> DependencyTree {
pub fn build(task: Box<dyn Task>) -> DependencyTree {
let dependencies = task
.dependencies()
.into_iter()

View file

@ -24,7 +24,7 @@ impl Task for ResolvePackageTask {
&mut self,
input: Vec<TaskParamType>,
context: &mut InstallerFramework,
messenger: &Fn(&TaskMessage),
messenger: &dyn Fn(&TaskMessage),
) -> Result<TaskParamType, String> {
assert_eq!(input.len(), 0);
let mut metadata: Option<PackageDescription> = None;

View file

@ -14,7 +14,7 @@ impl Task for SaveDatabaseTask {
&mut self,
input: Vec<TaskParamType>,
context: &mut InstallerFramework,
messenger: &Fn(&TaskMessage),
messenger: &dyn Fn(&TaskMessage),
) -> Result<TaskParamType, String> {
assert_eq!(input.len(), 0);
messenger(&TaskMessage::DisplayMessage(

View file

@ -23,7 +23,7 @@ impl Task for SaveExecutableTask {
&mut self,
input: Vec<TaskParamType>,
context: &mut InstallerFramework,
messenger: &Fn(&TaskMessage),
messenger: &dyn Fn(&TaskMessage),
) -> Result<TaskParamType, String> {
assert_eq!(input.len(), 0);
messenger(&TaskMessage::DisplayMessage(

View file

@ -19,7 +19,7 @@ impl Task for UninstallTask {
&mut self,
_: Vec<TaskParamType>,
_: &mut InstallerFramework,
messenger: &Fn(&TaskMessage),
messenger: &dyn Fn(&TaskMessage),
) -> Result<TaskParamType, String> {
messenger(&TaskMessage::DisplayMessage("Wrapping up...", 0.0));
Ok(TaskParamType::None)

View file

@ -18,7 +18,7 @@ impl Task for UninstallGlobalShortcutsTask {
&mut self,
input: Vec<TaskParamType>,
context: &mut InstallerFramework,
messenger: &Fn(&TaskMessage),
messenger: &dyn Fn(&TaskMessage),
) -> Result<TaskParamType, String> {
assert_eq!(input.len(), 0);

View file

@ -27,7 +27,7 @@ impl Task for UninstallPackageTask {
&mut self,
input: Vec<TaskParamType>,
context: &mut InstallerFramework,
messenger: &Fn(&TaskMessage),
messenger: &dyn Fn(&TaskMessage),
) -> Result<TaskParamType, String> {
assert_eq!(input.len(), 1);

View file

@ -24,7 +24,7 @@ impl Task for UninstallShortcutsTask {
&mut self,
input: Vec<TaskParamType>,
context: &mut InstallerFramework,
messenger: &Fn(&TaskMessage),
messenger: &dyn Fn(&TaskMessage),
) -> Result<TaskParamType, String> {
assert_eq!(input.len(), 0);