Skip to content

mox: How to invoke nullary functions (functions with 0 arguments)? #276

@cakekindel

Description

@cakekindel

hi! i'm working through adding mox builder support to my slack-blocks data structure library and can't find a way to call a nullary function; if i had:

struct Foo {
  bar: bool,
}

impl Foo {
  pub fn build() -> FooBuilder {
    FooBuilder { bar: false }
  }
}

struct FooBuilder {
  bar: bool
}

impl FooBuilder {
  pub fn bar(mut self) -> Self {
    self.bar = true;
    self
  }
}

My expectation is that there would be some syntax to invoke bar:

mox! {
  <Foo::build bar />
  <Foo::build bar={()} />
  <Foo::build bar=_ />
  <Foo::build bar() />
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions