Skip to content

Commit

Permalink
A lot more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog committed Aug 23, 2023
1 parent d90b411 commit fe8a183
Show file tree
Hide file tree
Showing 24 changed files with 1,383 additions and 635 deletions.
9 changes: 5 additions & 4 deletions book/src/template_literals.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ It expects a function with the signature `fn(&self, buf: &mut String) -> fmt::Re

```rust,noplaypen
use rune::{ContextError, Module};
use rune::runtime::Protocol;
use rune::runtime::{Protocol, Formatter};
use std::fmt::Write as _;
use std::fmt;
Expand All @@ -40,14 +40,15 @@ pub struct StatusCode {
}
impl StatusCode {
fn display(&self, buf: &mut String) -> fmt::Result {
write!(buf, "{}", self.inner)
#[rune::function(protocol = STRING_DISPLAY)]
fn string_display(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "{}", self.inner)
}
}
pub fn module() -> Result<Module, ContextError> {
let mut module = Module::new(["http"]);
module.associated_function(Protocol::STRING_DISPLAY, StatusCode::display)?;
module.function_meta(StatusCode::string_display)?;
Ok(module)
}
```
Expand Down
Loading

0 comments on commit fe8a183

Please sign in to comment.