Using no_std + alloc (#279)
Removed references to `std` and replaced them with references to `core` and `alloc`. Features `rocket` and `iron` still require `std`. Co-authored-by: Chris Wong <lambda.fairy@gmail.com>
This commit is contained in:
parent
6a3d3eca6e
commit
3eb4254ffb
4 changed files with 27 additions and 4 deletions
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
- Support `no_std` + `alloc`.
|
||||||
|
[#278](https://github.com/lambda-fairy/maud/issues/278)
|
||||||
|
|
||||||
## [0.22.2] - 2021-01-09
|
## [0.22.2] - 2021-01-09
|
||||||
|
|
||||||
- Don't require `?` suffix for empty attributes. The old syntax is kept for backward compatibility.
|
- Don't require `?` suffix for empty attributes. The old syntax is kept for backward compatibility.
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![no_std]
|
||||||
|
|
||||||
//! A macro for writing HTML templates.
|
//! A macro for writing HTML templates.
|
||||||
//!
|
//!
|
||||||
//! This documentation only describes the runtime API. For a general
|
//! This documentation only describes the runtime API. For a general
|
||||||
|
@ -7,7 +9,10 @@
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/maud/0.22.2")]
|
#![doc(html_root_url = "https://docs.rs/maud/0.22.2")]
|
||||||
|
|
||||||
use std::fmt::{self, Write};
|
extern crate alloc;
|
||||||
|
|
||||||
|
use alloc::string::String;
|
||||||
|
use core::fmt::{self, Write};
|
||||||
|
|
||||||
pub use maud_macros::{html, html_debug};
|
pub use maud_macros::{html, html_debug};
|
||||||
|
|
||||||
|
@ -89,8 +94,9 @@ impl<T: fmt::Display + ?Sized> Render for T {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub mod render {
|
pub mod render {
|
||||||
use crate::Render;
|
use crate::Render;
|
||||||
|
use alloc::string::String;
|
||||||
|
use core::fmt::Write;
|
||||||
use maud_htmlescape::Escaper;
|
use maud_htmlescape::Escaper;
|
||||||
use std::fmt::Write;
|
|
||||||
|
|
||||||
pub trait RenderInternal {
|
pub trait RenderInternal {
|
||||||
fn __maud_render_to(&self, w: &mut String);
|
fn __maud_render_to(&self, w: &mut String);
|
||||||
|
@ -167,7 +173,11 @@ pub const DOCTYPE: PreEscaped<&'static str> = PreEscaped("<!DOCTYPE html>");
|
||||||
|
|
||||||
#[cfg(feature = "iron")]
|
#[cfg(feature = "iron")]
|
||||||
mod iron_support {
|
mod iron_support {
|
||||||
|
extern crate std;
|
||||||
|
|
||||||
use crate::PreEscaped;
|
use crate::PreEscaped;
|
||||||
|
use alloc::boxed::Box;
|
||||||
|
use alloc::string::String;
|
||||||
use iron::headers::ContentType;
|
use iron::headers::ContentType;
|
||||||
use iron::modifier::{Modifier, Set};
|
use iron::modifier::{Modifier, Set};
|
||||||
use iron::modifiers::Header;
|
use iron::modifiers::Header;
|
||||||
|
@ -191,7 +201,10 @@ mod iron_support {
|
||||||
|
|
||||||
#[cfg(feature = "rocket")]
|
#[cfg(feature = "rocket")]
|
||||||
mod rocket_support {
|
mod rocket_support {
|
||||||
|
extern crate std;
|
||||||
|
|
||||||
use crate::PreEscaped;
|
use crate::PreEscaped;
|
||||||
|
use alloc::string::String;
|
||||||
use rocket::http::{ContentType, Status};
|
use rocket::http::{ContentType, Status};
|
||||||
use rocket::request::Request;
|
use rocket::request::Request;
|
||||||
use rocket::response::{Responder, Response};
|
use rocket::response::{Responder, Response};
|
||||||
|
@ -211,6 +224,7 @@ mod rocket_support {
|
||||||
mod actix_support {
|
mod actix_support {
|
||||||
use crate::PreEscaped;
|
use crate::PreEscaped;
|
||||||
use actix_web_dep::{Error, HttpRequest, HttpResponse, Responder};
|
use actix_web_dep::{Error, HttpRequest, HttpResponse, Responder};
|
||||||
|
use alloc::string::String;
|
||||||
use futures_util::future::{ok, Ready};
|
use futures_util::future::{ok, Ready};
|
||||||
|
|
||||||
impl Responder for PreEscaped<String> {
|
impl Responder for PreEscaped<String> {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![cfg_attr(not(test), no_std)]
|
||||||
|
|
||||||
//! Internal support code used by the [Maud] template engine.
|
//! Internal support code used by the [Maud] template engine.
|
||||||
//!
|
//!
|
||||||
//! You should not need to depend on this crate directly.
|
//! You should not need to depend on this crate directly.
|
||||||
|
@ -6,7 +8,10 @@
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/maud_htmlescape/0.17.0")]
|
#![doc(html_root_url = "https://docs.rs/maud_htmlescape/0.17.0")]
|
||||||
|
|
||||||
use std::fmt;
|
extern crate alloc;
|
||||||
|
|
||||||
|
use alloc::string::String;
|
||||||
|
use core::fmt;
|
||||||
|
|
||||||
/// An adapter that escapes HTML special characters.
|
/// An adapter that escapes HTML special characters.
|
||||||
///
|
///
|
||||||
|
|
|
@ -35,8 +35,9 @@ fn expand(input: TokenStream) -> TokenStream {
|
||||||
let markups = parse::parse(input);
|
let markups = parse::parse(input);
|
||||||
let stmts = generate::generate(markups, output_ident.clone());
|
let stmts = generate::generate(markups, output_ident.clone());
|
||||||
quote!({
|
quote!({
|
||||||
|
extern crate alloc;
|
||||||
extern crate maud;
|
extern crate maud;
|
||||||
let mut #output_ident = ::std::string::String::with_capacity(#size_hint);
|
let mut #output_ident = alloc::string::String::with_capacity(#size_hint);
|
||||||
#stmts
|
#stmts
|
||||||
maud::PreEscaped(#output_ident)
|
maud::PreEscaped(#output_ident)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue