Skip to main content

code_block

Function code_block 

Source
pub const fn code_block<'a, T: Display>(content: T) -> CodeBlock<'a, T>
Expand description

Shows content as a block of code, highlighted for a language such as rust if set (D-213).

The content cannot contain three backticks in a row.

discord.js counterpart: codeBlock.

ยงExamples

use djs_formatters::code_block;

assert_eq!(code_block("let x = 1;").to_string(), "```\nlet x = 1;\n```");
assert_eq!(code_block("let x = 1;").language("rust").to_string(), "```rust\nlet x = 1;\n```");