futursolo / stylist-rs

A CSS-in-Rust styling solution for WebAssembly Applications
https://crates.io/crates/stylist
MIT License
366 stars 22 forks source link

v0.13.0 the trait bound `stylist::StyleSource: std::convert::From<&str>` is not satisfied #153

Closed einsli closed 6 months ago

einsli commented 6 months ago

I follow the example as bellow

use stylist::Style;

let style_str = r#"
background-color: red;

.nested {
    background-color: blue;
    width: 100px
}
"#;

let style = Style::new(style_str).expect("Failed to create style");

the error is the trait bound stylist::StyleSource: std::convert::From<&str> is not satisfied the trait std::convert::From<stylist::ast::Sheet> is implemented for stylist::StyleSource required for &str to implement

here is the Cargo.toml

[dependencies]
stylist = {version="0.13.0",features=["yew","yew_use_style"]}
yew = { version = "0.21.0", features = ["csr"] }
WorldSEnder commented 6 months ago

Enable the parser feature.

In this specific case, rather use the style! macro to generate the style:

let style = style!(r#"
background-color: red;

.nested {
    background-color: blue;
    width: 100px
}
"#);
WorldSEnder commented 6 months ago

Duplicate of #152