Skip to content
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

Enable stable support 🎉 #219

Merged
merged 6 commits into from
Sep 28, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,7 @@ jobs:
- |
RUN_CLIPPY=true
rustup component add clippy --toolchain=nightly || RUN_CLIPPY=false
# As of right now, these need to be tested individually becuase `--workspace`
# (which is implied by `workspace = true`) cannot be used with `--features`
# This _may_ be resolved with the `--package` flag, however this requires
# opting in to a `-Z` unstable feature as of time of commit.
#
# Follow https://github.com/rust-lang/cargo/issues/5364 for updates.
- cargo test --manifest-path maud/Cargo.toml --features actix-web,iron,rocket
- cargo test --manifest-path maud_htmlescape/Cargo.toml
- cargo test --manifest-path maud_macros/Cargo.toml
- cargo test --all --all-features
- |
if $RUN_CLIPPY; then
CLIPPY_STATUS=0
Expand All @@ -26,12 +18,13 @@ jobs:
done
(exit $CLIPPY_STATUS)
fi
- name: "Unstable"
- name: "Stable"
rust: stable
script:
- cargo test --all --all-features
- name: "Benchmarks"
script:
- (cd benchmarks && cargo test --benches --features unstable)
- (cd benchmarks && cargo test --benches)
- name: "Documentation"
script:
- (cd docs && make -j$(nproc))
Expand Down
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,9 @@

Maud is an HTML template engine for Rust. It's implemented as a macro, `html!`, which compiles your markup to specialized Rust code. This unique approach makes Maud templates blazing fast, super type-safe, and easy to deploy.

Note that Maud depends on the unstable [procedural macro API][rustissue], and so requires the nightly version of Rust.

For more info on Maud, see the [official book][book].

[book]: https://maud.lambda.xyz/
[booksrc]: https://github.com/lambda-fairy/maud/tree/master/docs
[apiref]: https://docs.rs/maud/
[changelog]: https://github.com/lambda-fairy/maud/blob/master/CHANGELOG.md
[rustissue]: https://github.com/rust-lang/rust/issues/38356

## Stability

As of version 0.11, I am satisfied with the core syntax and semantics of the library. Development at this stage is focused on adding features and fixing bugs.

The underlying procedural macro API is still unstable though, so updating your compiler may break things. Please file an issue when this happens!
3 changes: 0 additions & 3 deletions benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ version = "0.1.2"
authors = ["Chris Wong <lambda.fairy@gmail.com>"]
edition = "2018"

[features]
unstable = ["maud/unstable"]

[dependencies]
maud = { path = "../maud" }
handlebars = "*"
Expand Down
6 changes: 3 additions & 3 deletions maud/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ default = []
# Web framework integrations
actix-web = ["actix-web-dep", "futures"]

# Unstable features
unstable = []

[dependencies]
maud_htmlescape = { version = "0.17.0", path = "../maud_htmlescape" }
maud_macros = { version = "0.22.0", path = "../maud_macros" }
Expand All @@ -28,6 +25,9 @@ rocket = { version = ">= 0.3, < 0.5", optional = true }
futures = { version = "0.3.0", optional = true }
actix-web-dep = { version = "2.0.0", optional = true, default-features = false, package = "actix-web" }

[build-dependencies]
rustc_version = "0.2.3"

[dev-dependencies]
trybuild = { version = "1.0.33", features = ["diff"] }

Expand Down
8 changes: 8 additions & 0 deletions maud/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use rustc_version::{version_meta, Channel};

fn main() {
match version_meta().unwrap().channel {
lambda-fairy marked this conversation as resolved.
Show resolved Hide resolved
Channel::Dev | Channel::Nightly => println!("cargo:rustc-cfg=unstable"),
Channel::Beta | Channel::Stable => {}
}
}
10 changes: 5 additions & 5 deletions maud/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(feature = "unstable", feature(min_specialization))]
#![cfg_attr(unstable, feature(min_specialization))]

//! A macro for writing HTML templates.
//!
Expand Down Expand Up @@ -78,28 +78,28 @@ pub trait Render {
}
}

#[cfg(not(feature = "unstable"))]
#[cfg(not(unstable))]
impl<T: fmt::Display + ?Sized> Render for T {
fn render_to(&self, w: &mut String) {
let _ = write!(Escaper::new(w), "{}", self);
}
}

#[cfg(feature = "unstable")]
#[cfg(unstable)]
impl<T: fmt::Display + ?Sized> Render for T {
default fn render_to(&self, w: &mut String) {
let _ = write!(Escaper::new(w), "{}", self);
}
}

#[cfg(feature = "unstable")]
#[cfg(unstable)]
impl Render for String {
fn render_to(&self, w: &mut String) {
let _ = Escaper::new(w).write_str(self);
}
}

#[cfg(feature = "unstable")]
#[cfg(unstable)]
impl Render for str {
fn render_to(&self, w: &mut String) {
let _ = Escaper::new(w).write_str(self);
Expand Down