https://github.com/sagebind/here
A dumb unquoted Heredoc macro for Rust just because I can
https://github.com/sagebind/here
Last synced: over 1 year ago
JSON representation
A dumb unquoted Heredoc macro for Rust just because I can
- Host: GitHub
- URL: https://github.com/sagebind/here
- Owner: sagebind
- License: mit
- Created: 2020-06-21T04:04:38.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-21T04:05:08.000Z (about 6 years ago)
- Last Synced: 2025-03-24T22:47:29.336Z (over 1 year ago)
- Language: Rust
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Here
A dumb unquoted Heredoc macro for Rust just because I can. Don't use it, its not worth the effort just to omit quotes from your string literals.
Requires nightly.
## Usage
This:
```rust
fn my_html() -> &'static str {
here::doc! {
Hello
}
}
```
gets turned into this (more or less):
```rust
fn my_html() -> &'static str {
r#"
Hello
"#
}
```
De-indentation is inferred automatically and all other whitespace is preserved. For certain scenarios depending on the text, having the text not wrapped in quotes might look better in your editor.
## How does it work?
The macro completely ignores the token stream given to it and instead generates a string from the source code file located at the call site. Yuck! Not to mention probably breaks incremental compilation.
## License
This project's source code and documentation is licensed under the MIT license. See the [LICENSE](LICENSE) file for details.