Skip to content

Commit

Permalink
Improve execute template
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed May 3, 2024
1 parent 0710a01 commit e0fe15c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion docs-test-gen/templates/execute.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ struct ExecuteMsg {}

#[entry_point]
pub fn execute(deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg) -> StdResult<Response> {
{{code}}
// this weird construction allows us to return a StdResult<Response> or () in the code
// it tricks the compiler into infering the correct generics
trait ValidReturn {}
impl ValidReturn for StdResult<Response<Empty>> {}
impl ValidReturn for () {}
fn assert_valid_return(_: &impl ValidReturn) {}

let ret = { {{code}} };
assert_valid_return(&ret);

Ok(Response::default())
}

#[test]
Expand Down

0 comments on commit e0fe15c

Please sign in to comment.