Skip to content

Commit

Permalink
clippy: fix type_complexity warning by introducing BoxedIncludeCallba…
Browse files Browse the repository at this point in the history
…ck type alias
  • Loading branch information
filnet authored and antiagainst committed Oct 25, 2020
1 parent 7da544e commit 41f59da
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions shaderc-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,11 +642,13 @@ impl Drop for Compiler {
/// Include callback status.
pub type IncludeCallbackResult = result::Result<ResolvedInclude, String>;

type BoxedIncludeCallback<'a> =
Box<dyn Fn(&str, IncludeType, &str, usize) -> IncludeCallbackResult + 'a>;

/// An opaque object managing options to compilation.
pub struct CompileOptions<'a> {
raw: *mut scs::ShadercCompileOptions,
include_callback_fn:
Option<Box<dyn Fn(&str, IncludeType, &str, usize) -> IncludeCallbackResult + 'a>>,
include_callback_fn: Option<BoxedIncludeCallback<'a>>,
}

/// Identifies the type of include directive. `Relative` is for include directives of the form
Expand Down Expand Up @@ -781,8 +783,7 @@ impl<'a> CompileOptions<'a> {

let f = Box::new(f);
let f_ptr = &*f as *const F;
self.include_callback_fn =
Some(f as Box<dyn Fn(&str, IncludeType, &str, usize) -> IncludeCallbackResult + 'a>);
self.include_callback_fn = Some(f as BoxedIncludeCallback<'a>);
unsafe {
scs::shaderc_compile_options_set_include_callbacks(
self.raw,
Expand Down

0 comments on commit 41f59da

Please sign in to comment.