Skip to content

Document ({ /* arbitrary Rust code */ }) #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
trombonehero opened this issue Feb 1, 2017 · 5 comments
Closed

Document ({ /* arbitrary Rust code */ }) #72

trombonehero opened this issue Feb 1, 2017 · 5 comments

Comments

@trombonehero
Copy link

I wasn't able to find anything in the Maud documentation about the fact that splices can contain arbitrary Rust code, including compound expressions. I did stumble on #11, which contains a comment referencing ${ ... } before I created a bug about type inference, but it would be useful if the documentation had an example of this kind of thing. For instance:

p ({
  let user:User = try![database.lookup(userid)];
  user.name
})

This is also an example of the kind of thing that can fail when using Maud @let directives: they don't accept type annotations, so I sometimes get "the type of this value must be known in this context" errors.

@ghost
Copy link

ghost commented Feb 1, 2017

You can use

@let ...;
@if let...;

@ghost
Copy link

ghost commented Feb 1, 2017

This style I supported but refused.

@ {
   // Arbitrary code here.
}

@lambda-fairy
Copy link
Owner

The documentation can be found at https://github.com/lfairy/maud-book. I'm too swamped with work at the moment to edit it myself, but if you have the time then I'd welcome a pull request.

I think @let not supporting type annotations is a bug. I've filed that as #73.

@trombonehero
Copy link
Author

Thanks! I've created lambda-fairy/maud-book#1.

@lambda-fairy
Copy link
Owner

I believe @trombonehero's PR closes this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants