pub fn adapt_env<Q, E>(
    mut self,
    env: &mut E,
  ) -> Result<BuiltProgram<B, Sem, Out, Q>, AdaptationFailure<B, Sem, Out, Uni>>
  where
    Q: UniformInterface<B, E>,
  {
    // first, try to create the new uniform interface
    let mut uniform_builder: UniformBuilder<B> =
      match unsafe { B::new_uniform_builder(&mut self.repr) } {
        Ok(repr) => UniformBuilder {
          repr,
          warnings: Vec::new(),
          _a: PhantomData,
        },

        Err(e) => return Err(AdaptationFailure::new(self, e)),
      };

    let uni = match Q::uniform_interface(&mut uniform_builder, env) {
      Ok(uni) => uni,
      Err(e) => {
        return Err(AdaptationFailure::new(
          self,
          ProgramWarning::Uniform(e).into(),
        ))
      }
    };

    let warnings = uniform_builder
      .warnings
      .into_iter()
      .map(|w| ProgramError::Warning(w.into()))
      .collect();

    let program = Program {
      repr: self.repr,
      uni,
      _sem: PhantomData,
      _out: PhantomData,
    };

    Ok(BuiltProgram { program, warnings })
  }
/// Create a new [`UniformInterface`] but keep the [`Program`] around without rebuilding it, by
/// using a mutable environment variable.
///
/// # Parametricity
///
/// - `Q` is the new [`UniformInterface`].
/// - `E` is the mutable environment variable.
Create a new [`UniformInterface`] but keep the [`Program`] around without rebuilding it, by
using a mutable environment variable.
Create a new [ ` UniformInterface ` ] but keep the [ ` Program ` ] around without rebuilding it by using a mutable environment variable .
pub fn adapt_env<Q, E>(
    mut self,
    env: &mut E,
  ) -> Result<BuiltProgram<B, Sem, Out, Q>, AdaptationFailure<B, Sem, Out, Uni>>
  where
    Q: UniformInterface<B, E>,
  {
    // first, try to create the new uniform interface
    let mut uniform_builder: UniformBuilder<B> =
      match unsafe { B::new_uniform_builder(&mut self.repr) } {
        Ok(repr) => UniformBuilder {
          repr,
          warnings: Vec::new(),
          _a: PhantomData,
        },
        Err(e) => return Err(AdaptationFailure::new(self, e)),
      };
    let uni = match Q::uniform_interface(&mut uniform_builder, env) {
      Ok(uni) => uni,
      Err(e) => {
        return Err(AdaptationFailure::new(
          self,
          ProgramWarning::Uniform(e).into(),
        ))
      }
    };
    let warnings = uniform_builder
      .warnings
      .into_iter()
      .map(|w| ProgramError::Warning(w.into()))
      .collect();
    let program = Program {
      repr: self.repr,
      uni,
      _sem: PhantomData,
      _out: PhantomData,
    };
    Ok(BuiltProgram { program, warnings })
  }
pub fn adapt_env < Q , E > ( mut self , env : & mut E , ) -> Result < BuiltProgram < B , Sem , Out , Q > , AdaptationFailure < B , Sem , Out , Uni > > where Q : UniformInterface < B , E > , { // first, try to create the new uniform interface let mut uniform_builder : UniformBuilder < B > = match unsafe { B :: new_uniform_builder ( & mut self . repr ) } { Ok ( repr ) => UniformBuilder { repr , warnings : Vec :: new ( ) , _a : PhantomData , } , Err ( e ) => return Err ( AdaptationFailure :: new ( self , e ) ) , } ; let uni = match Q :: uniform_interface ( & mut uniform_builder , env ) { Ok ( uni ) => uni , Err ( e ) => { return Err ( AdaptationFailure :: new ( self , ProgramWarning :: Uniform ( e ) . into ( ) , ) ) } } ; let warnings = uniform_builder . warnings . into_iter ( ) . map ( | w | ProgramError :: Warning ( w . into ( ) ) ) . collect ( ) ; let program = Program { repr : self . repr , uni , _sem : PhantomData , _out : PhantomData , } ; Ok ( BuiltProgram { program , warnings } ) }
Create a new [`UniformInterface`] but keep the [`Program`] around without rebuilding it, by
using a mutable environment variable.
Create a new [ ` UniformInterface ` ] but keep the [ ` Program ` ] around without rebuilding it by using a mutable environment variable .
mut self
env
&mut E
mut self
env
&mut E
parametricity
`Q` is the new [`UniformInterface`].
`E` is the mutable environment variable.
` Q ` is the new [ ` UniformInterface ` ] . ` E ` is the mutable environment variable .