Merge branch 'master' into stable

This commit is contained in:
Kogia-sima 2020-11-29 21:41:36 +09:00
commit 8e513bb6fd
26 changed files with 210 additions and 142 deletions

169
Cargo.lock generated
View File

@ -4,282 +4,281 @@
name = "ansi_term"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
dependencies = [
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi",
]
[[package]]
name = "ctor"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf6b25ee9ac1995c54d7adb2eff8cfffb7260bc774fb63c601ec65467f43cd9d"
dependencies = [
"quote 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
"quote",
"syn",
]
[[package]]
name = "difference"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
[[package]]
name = "glob"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "home"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2456aef2e6b6a9784192ae780c0f15bc57df0e918585282325e8c8ac27737654"
dependencies = [
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi",
]
[[package]]
name = "integration-tests"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"sailfish 0.2.2",
"sailfish-compiler 0.2.2",
"sailfish-macros 0.2.2",
"trybuild 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_assertions",
"sailfish",
"sailfish-compiler",
"sailfish-macros",
"trybuild",
]
[[package]]
name = "itoa"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e"
[[package]]
name = "itoap"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e804a5759b475f44377998918a7e3be9da3767056f5e77751ef7803893db0e9"
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "linked-hash-map"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a"
[[package]]
name = "memchr"
version = "2.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
[[package]]
name = "output_vt100"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9"
dependencies = [
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi",
]
[[package]]
name = "pretty_assertions"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427"
dependencies = [
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ctor 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
"difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"output_vt100 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ansi_term",
"ctor",
"difference",
"output_vt100",
]
[[package]]
name = "proc-macro2"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa"
dependencies = [
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea"
dependencies = [
"proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2",
]
[[package]]
name = "ryu"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]]
name = "sailfish"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"itoap 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"version_check 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"itoap",
"ryu",
"sailfish-macros",
"version_check",
]
[[package]]
name = "sailfish-compiler"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"home 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
"yaml-rust 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
"home",
"memchr",
"pretty_assertions",
"proc-macro2",
"quote",
"syn",
"yaml-rust",
]
[[package]]
name = "sailfish-macros"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
"sailfish-compiler 0.2.2",
"proc-macro2",
"sailfish-compiler",
]
[[package]]
name = "serde"
version = "1.0.111"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9124df5b40cbd380080b2cc6ab894c040a3070d995f5c9dc77e18c34a8ae37d"
dependencies = [
"serde_derive 1.0.111 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.111"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f2c3ac8e6ca1e9c80b8be1023940162bf81ae3cffbb1809474152f2ce1eb250"
dependencies = [
"proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "993948e75b189211a9b31a7528f950c6adc21f9720b6438ff80a7fa2f864cea2"
dependencies = [
"itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.111 (registry+https://github.com/rust-lang/crates.io-index)",
"itoa",
"ryu",
"serde",
]
[[package]]
name = "syn"
version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93a56fabc59dce20fe48b6c832cc249c713e7ed88fa28b0ee0a3bfcaae5fe4e2"
dependencies = [
"proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
name = "termcolor"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f"
dependencies = [
"winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-util",
]
[[package]]
name = "toml"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a"
dependencies = [
"serde 1.0.111 (registry+https://github.com/rust-lang/crates.io-index)",
"serde",
]
[[package]]
name = "trybuild"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39e3183158b2c8170db33b8b3a90ddc7b5f380d15b50794d22c1fa9c61b47249"
dependencies = [
"glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.111 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)",
"termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
"glob",
"lazy_static",
"serde",
"serde_json",
"termcolor",
"toml",
]
[[package]]
name = "unicode-xid"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
[[package]]
name = "version_check"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
[[package]]
name = "winapi"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
dependencies = [
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "yaml-rust"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39f0c922f1a334134dc2f7a8b67dc5d25f0735263feec974345ff706bcf20b0d"
dependencies = [
"linked-hash-map 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"linked-hash-map",
]
[metadata]
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
"checksum ctor 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "cf6b25ee9ac1995c54d7adb2eff8cfffb7260bc774fb63c601ec65467f43cd9d"
"checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
"checksum home 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2456aef2e6b6a9784192ae780c0f15bc57df0e918585282325e8c8ac27737654"
"checksum itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e"
"checksum itoap 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e804a5759b475f44377998918a7e3be9da3767056f5e77751ef7803893db0e9"
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
"checksum linked-hash-map 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a"
"checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
"checksum output_vt100 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9"
"checksum pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427"
"checksum proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa"
"checksum quote 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea"
"checksum ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
"checksum serde 1.0.111 (registry+https://github.com/rust-lang/crates.io-index)" = "c9124df5b40cbd380080b2cc6ab894c040a3070d995f5c9dc77e18c34a8ae37d"
"checksum serde_derive 1.0.111 (registry+https://github.com/rust-lang/crates.io-index)" = "3f2c3ac8e6ca1e9c80b8be1023940162bf81ae3cffbb1809474152f2ce1eb250"
"checksum serde_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)" = "993948e75b189211a9b31a7528f950c6adc21f9720b6438ff80a7fa2f864cea2"
"checksum syn 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)" = "93a56fabc59dce20fe48b6c832cc249c713e7ed88fa28b0ee0a3bfcaae5fe4e2"
"checksum termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f"
"checksum toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a"
"checksum trybuild 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "39e3183158b2c8170db33b8b3a90ddc7b5f380d15b50794d22c1fa9c61b47249"
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
"checksum version_check 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
"checksum yaml-rust 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "39f0c922f1a334134dc2f7a8b67dc5d25f0735263feec974345ff706bcf20b0d"

View File

@ -30,8 +30,8 @@ Dependencies:
```toml
[dependencies]
sailfish = "0.2.2"
sailfish-macros = "0.2.2"
sailfish = "0.2.3"
sailfish-macros = "0.2.3"
```
Template file (templates/hello.stpl):

View File

@ -1,6 +1,6 @@
[package]
name = "benches"
version = "0.2.2"
version = "0.2.3"
authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>", "Ryohei Machida <orcinus4627@gmail.com>"]
build = "src/build.rs"
edition = "2018"

View File

@ -4,8 +4,8 @@ In order to use sailfish templates, you have add two dependencies in your `Cargo
```toml
[dependencies]
sailfish = "0.2.2"
sailfish-macros = "0.2.2"
sailfish = "0.2.3"
sailfish-macros = "0.2.3"
```
`sailfish` crate contains runtime for rendering contents, and `sailfish-macros` serves you derive macros to compile and import the template files.

View File

@ -1,6 +1,6 @@
[package]
name = "sailfish-examples"
version = "0.2.2"
version = "0.2.3"
authors = ["Ryohei Machida <orcinus4627@gmail.com>"]
edition = "2018"
publish = false

View File

@ -1,6 +1,6 @@
[package]
name = "sailfish-compiler"
version = "0.2.2"
version = "0.2.3"
authors = ["Ryohei Machida <orcinus4627@gmail.com>"]
description = "Really fast, intuitive template engine for Rust"
homepage = "https://github.com/Kogia-sima/sailfish"

View File

@ -1,3 +1,5 @@
#![forbid(unsafe_code)]
#[macro_use]
mod error;

View File

@ -334,7 +334,7 @@ fn find_block_comment_end(haystack: &str) -> Option<usize> {
let mut depth = 1;
while let Some(p) = memchr2(b'*', b'/', remain.as_bytes()) {
let c = unsafe { *remain.as_bytes().get_unchecked(p) };
let c = remain.as_bytes()[p];
let next = remain.as_bytes().get(p + 1);
match (c, next) {
@ -344,14 +344,14 @@ fn find_block_comment_end(haystack: &str) -> Option<usize> {
return Some(offset);
}
depth -= 1;
remain = unsafe { remain.get_unchecked(p + 2..) };
remain = &remain[p + 2..];
}
(b'/', Some(b'*')) => {
depth += 1;
remain = unsafe { remain.get_unchecked(p + 2..) };
remain = &remain[p + 2..];
}
_ => {
remain = unsafe { remain.get_unchecked(p + 1..) };
remain = &remain[p + 1..];
}
}
}
@ -364,16 +364,14 @@ fn find_string_end(haystack: &str) -> Option<usize> {
let mut bytes = &haystack.as_bytes()[1..];
while let Some(p) = memchr2(b'"', b'\\', bytes) {
unsafe {
if *bytes.get_unchecked(p) == b'\"' {
// string terminator found
return Some(haystack.len() - (bytes.len() - p) + 1);
} else if p + 2 < bytes.len() {
// skip escape
bytes = bytes.get_unchecked(p + 2..);
} else {
break;
}
if bytes[p] == b'\"' {
// string terminator found
return Some(haystack.len() - (bytes.len() - p) + 1);
} else if p + 2 < bytes.len() {
// skip escape
bytes = &bytes[p + 2..];
} else {
break;
}
}

View File

@ -267,7 +267,7 @@ fn derive_template_impl(tokens: TokenStream) -> Result<TokenStream, syn::Error>
let tokens = quote! {
impl #impl_generics sailfish::TemplateOnce for #name #ty_generics #where_clause {
fn render_once_to_string(self, buf: &mut String) -> Result<(), sailfish::runtime::RenderError> {
fn render_once_to_string(self, buf: &mut String) -> std::result::Result<(), sailfish::runtime::RenderError> {
#include_bytes_seq;
use sailfish::runtime as __sf_rt;

View File

@ -64,7 +64,8 @@ pub fn rustfmt_block(source: &str) -> io::Result<String> {
let output = child.wait_with_output()?;
if output.status.success() {
let mut s = unsafe { String::from_utf8_unchecked(output.stdout) };
let mut s =
String::from_utf8(output.stdout).expect("rustfmt output is non-UTF-8!");
let brace_offset = s.find('{').unwrap();
s.replace_range(..brace_offset, "");
Ok(s)

View File

@ -1,6 +1,6 @@
[package]
name = "sailfish-macros"
version = "0.2.2"
version = "0.2.3"
authors = ["Ryohei Machida <orcinus4627@gmail.com>"]
description = "Really fast, intuitive template engine for Rust"
homepage = "https://github.com/Kogia-sima/sailfish"
@ -29,6 +29,6 @@ proc-macro2 = "1.0.11"
[dependencies.sailfish-compiler]
path = "../sailfish-compiler"
version = "0.2.2"
version = "0.2.3"
default-features = false
features = ["procmacro"]

View File

@ -1,3 +1,5 @@
#![forbid(unsafe_code)]
extern crate proc_macro;
use proc_macro::TokenStream;

View File

@ -1,6 +1,6 @@
[package]
name = "fuzzing-tests"
version = "0.2.2"
version = "0.2.3"
authors = ["Ryohei Machida <orcinus4627@gmail.com>"]
edition = "2018"
publish = false

View File

@ -1,6 +1,6 @@
[package]
name = "integration-tests"
version = "0.2.2"
version = "0.2.3"
authors = ["Kogia-sima <orcinus4627@gmail.com>"]
edition = "2018"
publish = false

View File

@ -20,7 +20,8 @@
#[test]
fn compile_error() {
std::env::set_var("SAILFISH_INTEGRATION_TESTS", "1");
let t = trybuild::TestCases::new();
t.compile_fail("tests/fails/*.rs");
if std::env::var("SAILFISH_INTEGRATION_TESTS").map_or(false, |v| v == "1") {
let t = trybuild::TestCases::new();
t.compile_fail("tests/fails/*.rs");
}
}

View File

@ -1,3 +1,13 @@
warning: unused import: `std::mem`
--> $DIR/mod.rs:12:5
|
12 | use std::mem;
| ^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: 1 warning emitted
error: expected boolean literal
--> $DIR/invalid_option_value.rs:5:38
|
@ -15,7 +25,7 @@ error[E0599]: no method named `render_once` found for struct `InvalidOptionValue
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `render_once`, perhaps you need to implement it:
candidate #1: `sailfish::TemplateOnce`
candidate #1: `TemplateOnce`
warning: unused import: `sailfish::TemplateOnce`
--> $DIR/invalid_option_value.rs:1:5

View File

@ -1,3 +1,13 @@
warning: unused import: `std::mem`
--> $DIR/mod.rs:12:5
|
12 | use std::mem;
| ^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: 1 warning emitted
error: `path` option must be specified.
--> $DIR/no_path.rs:4:10
|
@ -17,7 +27,7 @@ error[E0599]: no method named `render_once` found for struct `NoTemplate` in the
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `render_once`, perhaps you need to implement it:
candidate #1: `sailfish::TemplateOnce`
candidate #1: `TemplateOnce`
warning: unused import: `sailfish::TemplateOnce`
--> $DIR/no_path.rs:1:5

View File

@ -1,3 +1,13 @@
warning: unused import: `std::mem`
--> $DIR/mod.rs:12:5
|
12 | use std::mem;
| ^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: 1 warning emitted
error: keyword argument repeated.
--> $DIR/repeated_arguments.rs:6:21
|
@ -15,7 +25,7 @@ error[E0599]: no method named `render_once` found for struct `InvalidOptionValue
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `render_once`, perhaps you need to implement it:
candidate #1: `sailfish::TemplateOnce`
candidate #1: `TemplateOnce`
warning: unused import: `sailfish::TemplateOnce`
--> $DIR/repeated_arguments.rs:1:5

View File

@ -1,3 +1,13 @@
warning: unused import: `std::mem`
--> $DIR/mod.rs:12:5
|
12 | use std::mem;
| ^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: 1 warning emitted
error: Failed to compile template.
Caused by: Rust Syntax Error: LexError

View File

@ -1,3 +1,13 @@
warning: unused import: `std::mem`
--> $DIR/mod.rs:12:5
|
12 | use std::mem;
| ^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: 1 warning emitted
error: Failed to compile template.
Caused by: Parse error: Unterminated code block
@ -26,7 +36,7 @@ error[E0599]: no method named `render_once` found for struct `UnclosedDelimiter`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `render_once`, perhaps you need to implement it:
candidate #1: `sailfish::TemplateOnce`
candidate #1: `TemplateOnce`
warning: unused import: `sailfish::TemplateOnce`
--> $DIR/unclosed_delimter.rs:1:5

View File

@ -1,3 +1,13 @@
warning: unused import: `std::mem`
--> $DIR/mod.rs:12:5
|
12 | use std::mem;
| ^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: 1 warning emitted
error: Failed to compile template.
Caused by: Rust Syntax Error: expected expression

View File

@ -1,3 +1,13 @@
warning: unused import: `std::mem`
--> $DIR/mod.rs:12:5
|
12 | use std::mem;
| ^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: 1 warning emitted
error: Unknown option: `patth`
--> $DIR/unknown_option.rs:5:12
|
@ -15,7 +25,7 @@ error[E0599]: no method named `render_once` found for struct `UnknownOption` in
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `render_once`, perhaps you need to implement it:
candidate #1: `sailfish::TemplateOnce`
candidate #1: `TemplateOnce`
warning: unused import: `sailfish::TemplateOnce`
--> $DIR/unknown_option.rs:1:5

View File

@ -1,6 +1,6 @@
[package]
name = "sailfish"
version = "0.2.2"
version = "0.2.3"
authors = ["Ryohei Machida <orcinus4627@gmail.com>"]
description = "Really fast, intuitive template engine for Rust"
homepage = "https://github.com/Kogia-sima/sailfish"
@ -13,12 +13,18 @@ workspace = ".."
edition = "2018"
[features]
default = ["perf-inline"]
default = ["derive", "perf-inline"]
derive = ["sailfish-macros"]
perf-inline = []
[dependencies]
itoap = "0.1.0"
ryu = "1.0.4"
[dependencies.sailfish-macros]
path = "../sailfish-macros"
version = "0.2.3"
optional = true
[build-dependencies]
version_check = "0.9.2"

View File

@ -68,6 +68,11 @@ impl Buffer {
self.len = new_len;
}
pub(crate) fn truncate(&mut self, new_len: usize) {
assert!(new_len <= self.len);
self.len = new_len;
}
/// Increase the length of buffer by `additional` bytes
///
/// # Safety
@ -94,6 +99,7 @@ impl Buffer {
}
#[inline]
#[doc(hidden)]
pub fn clear(&mut self) {
self.len = 0;
}

View File

@ -47,7 +47,7 @@ impl<'a, T: Render> Render for Upper<'a, T> {
self.0.render(b)?;
let s = b.as_str()[old_len..].to_uppercase();
unsafe { b._set_len(old_len) };
b.truncate(old_len);
b.push_str(&*s);
Ok(())
}
@ -67,7 +67,7 @@ impl<'a, T: Render> Render for Lower<'a, T> {
self.0.render(b)?;
let s = b.as_str()[old_len..].to_lowercase();
unsafe { b._set_len(old_len) };
b.truncate(old_len);
b.push_str(&*s);
Ok(())
}
@ -77,7 +77,7 @@ impl<'a, T: Render> Render for Lower<'a, T> {
self.0.render_escaped(b)?;
let s = b.as_str()[old_len..].to_lowercase();
unsafe { b._set_len(old_len) };
b.truncate(old_len);
b.push_str(&*s);
Ok(())
}

View File

@ -70,23 +70,6 @@ impl From<fmt::Error> for RenderError {
pub type RenderResult = Result<String, RenderError>;
// #[inline(never)]
// pub fn _instantiate(table: Vec<Vec<usize>>) -> String {
// let mut buffer = Buffer::with_capacity(130000);
// buffer.push_str("<table>");
// for r1 in table {
// buffer.push_str("<tr><td>");
// for r2 in r1 {
// let _ = (&r2).render(&mut buffer);
// buffer.push_str("</td><td>");
// }
// unsafe { buffer._set_len(buffer.len() - 4) }
// buffer.push_str("</tr>");
// }
// buffer.push_str("</table>");
// buffer.into_string()
// }
#[cfg(test)]
mod tests {
use super::*;