impl DirSubst {
#[throws(AE)]
- pub fn setup_static_users
- <W, F: FnMut(StaticUserSetup) -> Result<W, AE>>
- (&mut self, layout: PresentationLayout, mut f: F)
- -> Vec<W>
+ pub fn setup_static_users(&mut self, layout: PresentationLayout)
+ -> Vec<StaticUserSetup>
{
#[throws(AE)]
fn mk(su: &DirSubst, layout: PresentationLayout, u: StaticUser)
StaticUser::iter().map(
|u| (||{
let ssu = mk(self, layout, u).context("create")?;
- let w = f(ssu).context("set up")?;
- Ok::<_,AE>(w)
+ Ok::<_,AE>(ssu)
})()
.with_context(|| format!("{:?}", u))
.context("make static user")
)
- .collect::<Result<Vec<W>,AE>>()?
+ .collect::<Result<Vec<StaticUserSetup>,AE>>()?
}
}
&mut |_|false
)?;
let spec = su.ds.game_spec_data()?;
- let [alice, bob]: [Player; 2] = su.ds.setup_static_users(
- default(),
- |sus| Ok(Player { nick: sus.nick, url: sus.url })
- )?
- .try_into().unwrap();
+ let [alice, bob]: [Player; 2] =
+ su.ds.setup_static_users(default())?
+ .into_iter().map(|sus| Player { nick: sus.nick, url: sus.url })
+ .collect::<ArrayVec<_>>().into_inner().unwrap();
let su_rc = Rc::new(RefCell::new(su));
tests(Ctx { opts, spec, su_rc, alice, bob })?;
impl Setup {
#[throws(AE)]
pub fn setup_static_users(&mut self, instance: &Instance) -> Vec<Window> {
- self.core.ds.clone().setup_static_users(self.opts.layout, |sus|{
+ self.core.ds.clone()
+ .setup_static_users(self.opts.layout)?
+ .into_iter().map(|sus|
+ {
let w = self.new_window(instance, sus.nick)?;
self.w(&w)?.get(sus.url)?;
self.w(&w)?.screenshot("initial", log::Level::Trace)?;
- Ok(w)
- })?
+ Ok::<_,AE>(w)
+ })
+ .collect::<Result<_,_>>()?
}
}