text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_prefix|>use quote::{ToTokens, quote, quote_spanned};
use syn::Expr;
use syn::buffer::Cursor;
use syn::parse::{Parse, ParseStream};
use syn::spanned::Spanned;
use super::html_dashed_name::HtmlDashedName;
use super::{HtmlChildrenTree, TagTokens};
use crate::props::Prop;
use crate::{Peek, PeekValue};
pub struct Ht... | fim | yewstack/yew | rust |
<|fim_prefix|>use proc_macro2::{Ident, Span, TokenStream};
use quote::quote;
use syn::parse::ParseStream;
use syn::spanned::Spanned;
use syn::{Expr, Stmt};
use super::{
HtmlChildrenTree, HtmlTree, ToNodeIterator, parse_preamble_stmts, stmts_have_divergent,
};
/// Determines if an expression is guaranteed to alway... | fim | yewstack/yew | rust |
use proc_macro2::{Delimiter, TokenStream};
use quote::{ToTokens, quote, quote_spanned};
use syn::buffer::Cursor;
use syn::parse::{Parse, ParseStream};
use syn::spanned::Spanned;
use syn::{Expr, Pat, Stmt, Token, braced, token};
use super::html_block::html_macro_call_span;
use super::html_node::HtmlNode;
use super::{Ht... | fim | yewstack/yew | rust |
<|fim_prefix|>use proc_macro2::{Span, TokenStream};
use quote::{ToTokens, quote, quote_spanned};
use syn::buffer::Cursor;
use syn::parse::{Parse, ParseStream, Result};
use syn::spanned::Spanned;
use syn::{Expr, Lit};
use super::ToNodeIterator;
use crate::PeekValue;
use crate::stringify::Stringify;
pub enum HtmlNode {... | fim | yewstack/yew | rust |
<|fim_prefix|>use proc_macro2::TokenStream;
use quote::{ToTokens, quote};
use sy<|fim_suffix|> }
let body_stream;
braced!(body_stream in input);
let (stmts, body, deprecations) = parse_loop_body(&body_stream, "while")?;
Ok(Self {
cond,
stmts,
b... | fim | yewstack/yew | rust |
<|fim_suffix|> emit_warning!(
quote::quote! {#tag_name}.span(),
"All `<img>` tags should have an `alt` attribute which provides a \
human-readable description "
)
}
}
}
}
<|fim_prefix|>//! Lints to catch possible misu... | fim | yewstack/yew | rust |
<|fim_suffix|>{
let children = &self.children;
let vlist = match children.fully_keyed() {
Some(true) => quote! {
::yew::virtual_dom::VList::__macro_new(#children, ::std::option::Option::None, ::yew::virtual_dom::FullyKeyedState::KnownFullyKeyed... | fim | yewstack/yew | rust |
<|fim_suffix|> }
}
'<' => angle_count += 1,
_ => {}
};
}
inner_trees.push(next);
}
Ok((inner_trees.into_iter().collect(), div, gt))
}
/// Generate tokens which can be used in `syn::E... | fim | yewstack/yew | rust |
<|fim_prefix|>//! This crate provides Yew's procedural macro `html!` which allows using JSX-like syntax
//! for generating html and the `Properties` derive macro for deriving the `Properties` trait
//! for components.
//!
//! ```
//! use yew::prelude::*;
//!
//! struct Component;
//!
//! #[derive(Properties, PartialEq)... | fim | yewstack/yew | rust |
<|fim_prefix|>use std::convert::TryFrom;
use proc_macro2::{Ident, Span, TokenStream};
use quote::{ToTokens, quote, quote_spanned};
use syn::Expr;
use syn::parse::{Parse, ParseStream};
use syn::spanned::Spanned;
use syn::token::DotDot;
use super::{CHILDREN_LABEL, Prop, PropLabel, Props, SpecialProps};
use crate::html_... | fim | yewstack/yew | rust |
<|fim_prefix|>use std::collections::HashSet;
use std::sync::LazyLock;
use syn::parse::{Parse, ParseStream};
use super::{Prop, Props, SpecialProps};
pub struct ElementProps {
pub attributes: Vec<Prop>,
pub listeners: Vec<Prop>,
pub classes: Option<Prop>,
pub booleans: Vec<Prop>,
pub value: Option<... | fim | yewstack/yew | rust |
<|fim_prefix|>mod component;
mod<|fim_suffix|>use component::*;
pub use element::*;
pub use prop::*;
pub use prop_macro::PropsMacroInput;
const CHILDREN_LABEL: &str = "children";
<|fim_middle|> element;
mod prop;
mod prop_macro;
pub <|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>use std::convert::TryFrom;
use std::ops::{Deref, DerefMut};
use proc_macro2::{Spacing, Span, TokenStream, TokenTree};
use quote::{ToTokens, quote, quote_spanned};
use syn::parse::{Parse, ParseBuffer, ParseStream};
use syn::spanned::Spanned;
use syn::token::Brace;
use syn::{
Block, Expr, ExprBlock, Ex... | fim | yewstack/yew | rust |
<|fim_prefix|>use std::convert::TryInto;
use proc_macro2::TokenStream;
use quote::{ToTokens, quote_spanned};
use syn::parse::{Parse, ParseStream};
use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
use syn::token::Brace;
use syn::{Expr, Token, TypePath};
use super::{ComponentProps, Prop, PropLabel, PropList,... | fim | yewstack/yew | rust |
use std::borrow::Cow;
use proc_macro2::{Span, TokenStream};
use quote::{ToTokens, quote_spanned};
use syn::spanned::Spanned;
use syn::{Expr, Lit, LitStr};
/// Stringify a value at runtime.
fn stringify_at_runtime(src: impl ToTokens) -> TokenStream {
quote_spanned! {src.span().resolved_at(Span::call_site())=>
... | fim | yewstack/yew | rust |
<|fim_prefix|>use proc_macro2::TokenStream;
use quote::quote;
use syn::parse::{Parse, ParseStream};
use syn::{Expr, ExprClosure, ReturnType, Token, Type};
#[derive(Debug)]
pub struct PreparedState {
closure: ExprClosure,
return_type: Type,
deps: Expr,
}
impl Parse for PreparedState {
fn parse(input: P... | fim | yewstack/yew | rust |
use proc_macro2::TokenStream;
use quote::quote;
use syn::parse::{Parse, ParseStream};
use syn::{Expr, ExprClosure, ReturnType, Token, Type};
#[derive(Debug)]
pub struct TransitiveState {
closure: ExprClosure,
return_type: Type,
deps: Expr,
}
impl Parse for TransitiveState {
fn parse(input: ParseStream... | fim | yewstack/yew | rust |
<|fim_prefix|>use yew::prelude::*;
fn compile_pass() {
classes!(42);
classes!(42.0)<|fim_suffix|>");
classes!(vec![42]);
let some = Some(42);
let none: Option<u32> = None;
classes!(some);
classes!(none);
classes!("one", 42);
classes!("one", "two three", "four");
}
fn main() {}
... | fim | yewstack/yew | rust |
<|fim_prefix|>#![no_implicit_prelude]
// Shadow primitives
#[allow(non_camel_case_types)]
pub struct bool;
#[allow(non_camel_case_types)]
pub struct char;
#[allow(non_camel_case_types)]
pub struct f32;
#[allow(non_camel_case_types)]
pub <|fim_suffix|>one", "two"]);
// single array
::yew::classes!(["one", "two... | fim | yewstack/yew | rust |
<|fim_suffix|>l.rs");
}
<|fim_prefix|>#[allow(dead_code)]
#[rustversion::attr(stable(1.85.0), test)]
fn classes_macro() {
let t = trybuild::TestCases::new();
t.pass("tests/classes_ma<|fim_middle|>cro/*-pass.rs");
t.compile_fail("tests/classes_macro/*-fai<|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>#![recursion_limit = "128"]
use yew::prelude::*;
mod t1 {
use super::*;
#[derive(Clone)]
struct Value;
#[derive(Clone, Properties, PartialEq)]
pub struct Props {
// ERROR: optional params must implement default
#[prop_or_default]
v<|fim_suffix|>ps { } };
}... | fim | yewstack/yew | rust |
<|fim_suffix|>_props {
#[derive(::std::cmp::PartialEq, ::yew::Properties)]
struct Props {
required: ::std::option::Option<usize>,
#[prop_or_default]
optional: ::std::option::Option<usize>
}
#[::yew::component]
fn Inner(_props: &Props) -> ::yew::html::Html {
::yew::ht... | fim | yewstack/yew | rust |
<|fim_prefix|>#[allow(dead_code)]
#[rustversion::attr(stable(1.85.0), test)]
fn derive_props() {
let t = trybuild::TestCases::new();
<|fim_suffix|>ompile_fail("tests/derive_props/fail.rs");
}
<|fim_middle|> t.pass("tests/derive_props/pass.rs");
t.c<|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>#[allow(dead_code)]
#[rustversion::attr(stable(1.85.0), test)]
fn tests() {
let t = trybuild::TestCases::new();
t.pass("tests/function_componen<|fim_suffix|>n_component_attr/*-fail.rs");
}
<|fim_middle|>t_attr/*-pass.rs");
t.compile_fail("tests/functio<|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>use yew::prelude::*;
#[derive(Clone, Prop<|fim_suffix|>
fn main() {}
<|fim_middle|>erties, PartialEq)]
struct Props {
a: usize,
}
#[component(Comp)]
struct Test;
<|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>use yew::prelude::*;
#[derive(Clone, Properties, PartialEq)]
struct Props {
a: usize,
}
#[component<|fim_suffix|>props: &Props) -> Html {
html! {
<p>
{ props.a }
</p>
}
}
fn main() {}
<|fim_middle|>(Comp)]
async fn comp(<|endoftext|> | fim | yewstack/yew | rust |
<|fim_suffix|> { props.a }
</p>
}
}
fn main() {}
<|fim_prefix|>use yew::prelude::*;
#[derive(Clone, Properties, PartialEq)]
struct Props {
a: usize,
}
#[component(let)]
fn comp(props: &Props) -> Html {
html! {
<p>
{ props.a }
</p>
}
}
#[component(x, y, ... | fim | yewstack/yew | rust |
<|fim_prefix|>use yew::prelude::*;
#[derive(Clone, Properties, Parti<|fim_suffix|>/p>
}
}
fn main() {}
<|fim_middle|>alEq)]
struct Props {
a: usize,
}
#[component(Comp)]
fn comp(props: Props) -> Html {
html! {
<p>
{ props.a }
<<|endoftext|> | fim | yewstack/yew | rust |
<|fim_suffix|>&Props) {}
#[component(Comp)]
fn comp(_props: &Props) -> u32 {
1
}
fn main() {}
<|fim_prefix|>use yew::prelude::*;
#[derive(Clone, P<|fim_middle|>roperties, PartialEq)]
struct Props {
a: usize,
}
#[component(Comp1)]
fn comp_1(_props: <|endoftext|> | fim | yewstack/yew | rust |
<|fim_suffix|>#[component(Comp)]
const fn comp(props: &Props) -> Html {
html! {
<p>
{ props.a }
</p>
}
}
fn main() {}
<|fim_prefix|>use yew::prelude::*;
#[derive(Clone, Pr<|fim_middle|>operties, PartialEq)]
struct Props {
a: usize,
}
<|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>use yew::prelude::*;
#[derive(Clone, Properties, PartialEq)]
struct Props {
a: usize,
}
#[component(Comp)]
extern "C"<|fim_suffix|> html! {
<p>
{ props.a }
</p>
}
}
fn main() {}
<|fim_middle|> fn comp(props: &Props) -> Html {
<|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>use yew::prelude::*;
#[derive(Clone, Properties,<|fim_suffix|> }
}
fn main() {}
<|fim_middle|> PartialEq)]
struct Props {
a: usize,
}
#[component(Comp)]
fn comp<'a>(props: &'a Props) -> Html {
html! {
<p>
{ props.a }
</p>
<|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>
// Shadow primitives
#[allow(non_camel_case_types)]
pub struct bool;
#[allow(non_camel_case_types)]
pub struct char;
#[allow(non_camel_case_types)]
pub stru<|fim_suffix|>>
}
}
#[::yew::component(ConstGenerics)]
fn const_generics<const N: ::std::primitive::i32>() -> ::yew::Html {
::yew::html! {
... | fim | yewstack/yew | rust |
<|fim_prefix|>use yew::prelude::*;
#[derive(Clone, Properties, PartialEq)]
struct Props {
<|fim_suffix|>{ <Comp<INVALID> /> };
// parameter doesn't match bounds
html! { <Comp<MissingTypeBounds> /> };
// missing type param
html! { <Comp /> };
}
fn main() {}
<|fim_middle|> a: usize,
}
#[component(C... | fim | yewstack/yew | rust |
use yew::prelude::*;
#[derive(Debug, PartialEq, Clone)]
struct Ctx;
#[component]
fn Comp() -> Html {
if let Some(_m) = use_context::<Ctx>() {
use_context::<Ctx>().unwrap();
todo!()
}
let _ = || {
use_context::<Ctx>().unwrap();
todo!()
};
for _ in 0..10 {
u... | fim | yewstack/yew | rust |
<|fim_suffix|>xt::<Ctx>() };
match ::yew::prelude::use_context::<Ctx>() {
::std::prelude::rust_2021::Some(_) => {
::std::todo!()
}
::std::prelude::rust_2021::None => {
::std::todo!()
}
}
}
fn main() {}
<|fim_prefix|>
#[derive(
::std::prelude::rust_20... | fim | yewstack/yew | rust |
<|fim_prefix|>use yew::prelude::*<|fim_suffix|>Comp)]
fn comp(props: &'static Props) -> Html {
html! {
<p>
{ props.a }
</p>
}
}
fn main() {}
<|fim_middle|>;
#[derive(Clone, Properties, PartialEq)]
struct Props {
a: usize,
}
#[component(<|endoftext|> | fim | yewstack/yew | rust |
use yew::prelude::*;
#[derive(Clone, Properties, PartialEq)]
struct Props {
a: usize,
}
#[component(Comp)]
fn comp(props: &Props, invalid: String) -> Html {
html! {
<p>
{ props.a }
{ invalid }
</p>
}
}
#[component(Comp)]
fn comp3(props: &Props, invalid: String, ano... | fim | yewstack/yew | rust |
<|fim_prefix|>use yew::prelude::*;
#[derive(Clone, Properties, PartialEq)]
str<|fim_suffix|>omponent(Comp)]
fn comp(props: &mut Props) -> Html {
html! {
<p>
{ props.a }
</p>
}
}
fn main() {}
<|fim_middle|>uct Props {
a: usize,
}
#[c<|endoftext|> | fim | yewstack/yew | rust |
#[derive(::yew::prelude::Properties, ::std::prelude::rust_2021::PartialEq,)]
struct Props {
a: usize,
}
#[::yew::prelude::component]
fn Comp(props: &Props) -> ::yew::prelude::Html {
::yew::prelude::html! {
<p>
{ props.a }
</p>
}
}
fn main() {
let _ = ::yew::prelude::html! ... | fim | yewstack/yew | rust |
<|fim_suffix|> _phantom: ::std::marker::PhantomData<A>,
}
impl<A> ::std::cmp::PartialEq for CompProps<A> {
fn eq(&self, _rhs: &Self) -> bool {
true
}
}
#[::yew::prelude::component(Comp)]
pub fn comp<A = ()>(_props: &CompProps<A>) -> ::yew::prelude::Html {
::std::todo!()
}
#[::yew::prelude::compo... | fim | yewstack/yew | rust |
<|fim_suffix|>e_types)]
pub struct bool;
#[allow(non_camel_case_types)]
pub struct char;
#[allow(non_camel_case_types)]
pub struct f32;
#[allow(non_camel_case_types)]
pub struct f64;
#[allow(non_camel_case_types)]
pub struct i128;
#[allow(non_camel_case_types)]
pub struct i16;
#[allow(non_camel_case_types)]
pub struct ... | fim | yewstack/yew | rust |
<|fim_prefix|>use yew::prelude::*;
#[derive(Clone, Properties, PartialEq)]
struct Props {
a: usize,
}
struct <|fim_suffix|> }
}
fn main() {}
<|fim_middle|>Test;
impl Test {
#[component(Comp)]
fn comp(self, props: &Props) -> Html {
html! {
<p>
{ props.a }
... | fim | yewstack/yew | rust |
#![no_implicit_prelude]
// Shadow primitives
#[allow(non_camel_case_types)]
pub struct bool;
#[allow(non_camel_case_types)]
pub struct char;
#[allow(non_camel_case_types)]
pub struct f32;
#[allow(non_camel_case_types)]
pub struct f64;
#[allow(non_camel_case_types)]
pub struct i128;
#[allow(non_camel_case_types)]
pub s... | fim | yewstack/yew | rust |
<|fim_prefix|>use yew::prelude::*;
#[hook]
fn use_reducer_default_action<T>() -> T::Action<|fim_suffix|>here
T: Reducible + 'static,
T::Action: Default + 'static,
{
T::Action::default()
}
fn main() {}
<|fim_middle|>
w<|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>#![no_implicit_prelude]
#[::yew::prelude::hook]
fn use_a_co<|fim_suffix|> N
}
fn main() {}
<|fim_middle|>nst<const N: u32>() -> u32 {
<|endoftext|> | fim | yewstack/yew | rust |
<|fim_suffix|>str>) {
::std::todo!()
}
fn main() {}
<|fim_prefix|>#![no_implicit_prelude]
#[::yew::prelude::hook]
fn use_boxed_fn(_f: ::std::boxed::Box<d<|fim_middle|>yn::std::ops::Fn(&str) -> &<|endoftext|> | fim | yewstack/yew | rust |
// we need to re-test the macro hygiene here as it uses a different implementation for impl traits.
#![no_implicit_prelude]
#[::yew::prelude::hook]
fn use_some_string(a: impl ::std::convert::Into<::std::string::String>) -> ::std::string::String {
a.into()
}
#[::yew::prelude::hook]
fn use_impl_fn<T, U>(_callback: ... | fim | yewstack/yew | rust |
<|fim_suffix|>a () {
input
}
fn main() {}
<|fim_prefix|>#![no_implicit_prelude]
#[::yew::functional::hook]
fn use_as_is<'a>(in<|fim_middle|>put: &'a ()) -> &'<|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>#![deny(unused_must_use)]
use yew::prelude::*;
fn no<|fim_suffix|>main() {}
<|fim_middle|>t_a_hook() {
use_effect_with((), |_| {});
}
fn <|endoftext|> | fim | yewstack/yew | rust |
#![deny(unused_must_use)]
use yew::prelude::*;
#[hook]
fn use_my_effect() {
use_effect_with((), |_| {});
}
#[component]
fn Comp() -> Html {
use_effect_with((), |_| {});
use_my_effect();
html! {}
}
fn main() {}
<|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>#![no_implicit_prelude]
#[::yew::prelude::hook]
fn use_deref_as_u32() -> impl ::std::ops::Deref<Target = ::std::primitive:<|fim_suffix|> ::std::rc::Rc::new(0)
}
fn main() {}
<|fim_middle|>:u32> {
<|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>#![no_implicit_prelude]
#[::yew::p<|fim_suffix|>::str {
f
}
fn main() {}
<|fim_middle|>relude::hook]
fn use_str_ref(f: &::std::primitive::str) -> &::std::primitive<|endoftext|> | fim | yewstack/yew | rust |
use std::marker::PhantomData;
pub struct QueryState<T> {
p: PhantomData<T>
}
pub trait MyTrait {
type Associated;
}
#[yew::hook]
pub fn use_query_state<Props>(
_selector: impl yew::html::IntoPropValue<bool>,
) -> QueryState<Props::Associated>
where
Props: MyTrait,
{
QueryState::<Props::Associate... | fim | yewstack/yew | rust |
<|fim_suffix|>odo!()
}
}
loop {
use_context::<Ctx>().unwrap();
todo!()
}
}
fn main() {}
<|fim_prefix|>use yew::prelude::*;
#[derive(Debug, PartialEq, Clone)]
struct Ctx;
#[hook]
fn use_some_html() -> Html {
if let Some(_m) = use_context::<Ctx>() {
<|fim_middle|> use_co... | fim | yewstack/yew | rust |
<|fim_suffix|>{
::yew::prelude::use_context::<Ctx>().unwrap();
if let ::std::prelude::rust_2021::Some(_m) = ::yew::prelude::use_context::<Ctx>() {
::std::todo!()
}
let _ctx = { ::yew::prelude::use_context::<Ctx>() };
match ::yew::prelude::use_context::<Ctx>() {
::std::prelude::rus... | fim | yewstack/yew | rust |
<|fim_prefix|>use yew::prelude::*;
#[hook]
pub fn use_some_macro_inner(val: &str) -> String {
use_st<|fim_suffix|> {
<div>{content}</div>
}
}
fn main() {}
<|fim_middle|>ate(|| val.to_owned()).to_string()
}
macro_rules! use_some_macro {
() => {
use_some_macro_inner("default str")
};
... | fim | yewstack/yew | rust |
<|fim_prefix|>#![no_implicit_prelude]
#[::yew::functional::hook]
pub fn use_some_macro_inner(val: &str)<|fim_suffix|> let b = use_some_macro!("b");
::yew::html! {
<div>{a}{b}</div>
}
}
fn main() {}
<|fim_middle|> -> ::std::string::String {
let state = ::yew::functional::use_state(|| ::std::borrow... | fim | yewstack/yew | rust |
<|fim_suffix|>fail("tests/hook_attr/*-fail.rs");
}
<|fim_prefix|>#[allow(dead_code)]
#[rustversion::attr(stable(1.85.0), test)]
fn tests() {
let t = trybuild::TestCases::new();
t.pass("tests/ho<|fim_middle|>ok_attr/*-pass.rs");
t.compile_<|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>use yew::prelude::*;
use yew_macro::{use_prepar<|fim_suffix|>(|_| { todo!() }, 123)?;
use_prepared_state_without_closure!(|_| -> u32 { todo!() })?;
use_prepared_state_without_closure!(|_| -> u32 { todo!() }, 123)?;
use_prepared_state_without_closure!(async |_| -> u32 { todo!() })?;
Ok(... | fim | yewstack/yew | rust |
<|fim_prefix|>use yew::prelude::*;
use yew_macro::{use_transitive_state_with_closure, use_transitive_state_without_closure};
#[component]
fn Comp() -> HtmlResult {
use_transitive_state_with_closure!(123)?;
use_transitive_state_with_closure!(|_| { todo!() }, 123)?;
use_transitive_state_with_closure!(123, ... | fim | yewstack/yew | rust |
<|fim_suffix|>s("tests/hook_macro/*-pass.rs");
t.compile_fail("tests/hook_macro/*-fail.rs");
}
<|fim_prefix|>#[al<|fim_middle|>low(dead_code)]
#[rustversion::attr(stable(1.85.0), test)]
fn tests() {
let t = trybuild::TestCases::new();
t.pas<|endoftext|> | fim | yewstack/yew | rust |
<|fim_suffix|>ches() {
let cond = true;
let _ = html! {
<div>{ if cond { html! { <span>{"yes"}</span> } } else { html! { <span>{"no"}</span> } } }</div>
};
}
fn main() {
compile_error!("This macro call exists to deliberately fail the compilation of the test so we can verify output of deprecatio... | fim | yewstack/yew | rust |
<|fim_prefix|>#![deny(deprecated)]
use yew::prelude::*;
#[allow(deprecated)]
fn silence_unnecessary_root_fragment() {
let _ = html! { <><div/></> };
}
#[allow(deprecated)]
fn silence_unnecessary_if_fragment() {
let _ = html! { if true { <<|fim_suffix|> match status {
0 => html! { <span>{"l... | fim | yewstack/yew | rust |
<|fim_suffix|> t.compile_fail("tests/html_deprecation/fail.rs");
}
<|fim_prefix|>#[allow(dead_code)]
#[rustversion::attr(st<|fim_middle|>able(1.85.0), test)]
fn test_html_deprecation() {
let t = trybuild::TestCases::new();
t.pass("tests/html_deprecation/pass.rs");
<|endoftext|> | fim | yewstack/yew | rust |
<|fim_suffix|>tput of lints");
}
<|fim_prefix|>use yew::prelude::*;
fn main() {
let bad_a = html! {
<a>{ "I don't have a href attribute" }</a>
};
let bad_a_2 = html! {
<a href="#">{ "I have a malformed href attribute" }</a>
};
let bad_a_3 = html! {
<a href="javascript:void(0... | fim | yewstack/yew | rust |
<|fim_prefix|>#[allow(dead_code)]
#[cfg(yew_lints)]
#[r<|fim_suffix|>ew();
t.compile_fail("tests/html_lints/fail.rs");
}
<|fim_middle|>ustversion::attr(nightly, test)]
fn test_html_lints() {
let t = trybuild::TestCases::n<|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>#![no_implicit_prelude]
// Shadow primitives
#[allow(non_camel_case_types)]
pub struct bool;
#[allow(non_camel_case_types)]
pub struct char;
#[allow(non_camel_case_types)]
pub struct f32;
#[allow(non_camel_case_types)]
pub struct f64;
#[allow(non_camel_case_types)]
pub struct i128;
#[allow(non_camel_case... | fim | yewstack/yew | rust |
<|fim_suffix|>>
};
}
fn main() {}
<|fim_prefix|>use yew::prelude::*;
fn compile_fail() {
let not_tree = || ();
html! {
<|fim_middle|> <div>{ not_tree() }</div>
};
html! {
<div>{ for (0..3).map(|_| not_tree()) }</div<|endoftext|> | fim | yewstack/yew | rust |
<|fim_suffix|>string("Hello") } };
let msg = "Hello";
_ = ::yew::html! { <div>{ msg }</div> };
let subview = ::yew::html! { "subview!" };
_ = ::yew::html! { <div>{ subview }</div> };
let subview = || ::yew::html! { "subview!" };
_ = ::yew::html! { <div>{ subview() }</div> };
_ = ::yew::h... | fim | yewstack/yew | rust |
<|fim_prefix|>#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::yew::Properties)]
pub struct ContainerProps {
#[prop_or_default]
pub children: ::yew::Html,
}
#[::yew::component]
fn Container(_props: &ContainerProps) -> ::yew::Html {
::yew::html! {}
}
#[derive(::std::clone::Clone, ::std::cmp::PartialE... | fim | yewstack/yew | rust |
// Shadow primitives
#[allow(non_camel_case_types)]
pub struct bool;
#[allow(non_camel_case_types)]
pub struct char;
#[allow(non_camel_case_types)]
pub struct f32;
#[allow(non_camel_case_types)]
pub struct f64;
#[allow(non_camel_case_types)]
pub struct i128;
#[allow(non_camel_case_types)]
pub struct i16;
#[allow(non_ca... | fim | yewstack/yew | rust |
<|fim_prefix|>use yew::html::ChildrenRenderer;
use yew::prelude::*;
#[derive(Clone, Properties, PartialEq)]
pub struct ChildProperties {
#[prop_or_default]
pub string: String,
pub int: i32,
}
pub struct Child;
impl Component for Child {
type Message = ();
type Properties = ChildProperties;
fn... | fim | yewstack/yew | rust |
<|fim_prefix|>// Shadow primitives
#[allow(non_camel_case_types)]
pub struct bool;
#[allow(non_camel_case_types)]
pub struct char;
#[allow(non_camel_case_types)]
pub struct f32;
#[allow(non_camel_case_types)]
pub struct f64;
#[allow(non_camel_case_types)]
pub struct i128;
#[allow(non_camel_case_types)]
pub struct i16;
... | fim | yewstack/yew | rust |
<|fim_suffix|>le_fail() {
html! { <Unimplemented /> };
}
fn main() {}
<|fim_prefix|>use yew::prelude::*;
struct Unimplemented;<|fim_middle|>
fn compi<|endoftext|> | fim | yewstack/yew | rust |
<|fim_suffix|>div> };
}
<|fim_prefix|>// Custom types with From<T> for VNode or Display do not automatically work
// in html! blocks, because blocks require In<|fim_middle|>toPropValue<VNode>, not Into<VNode>.
//
// A blanket `impl<T: Into<VNode>> IntoPropValue<VNode> for T` would fix this
// but conflicts with the ide... | fim | yewstack/yew | rust |
<|fim_suffix|>om::VNode::VTag(ref vtag) if vtag.tag() == "input")
);
}
<|fim_prefix|>#![no_implicit_prelude]
// Shadow primitives
#[allow(non_camel_case_types)]
pub struct bool;
#[allow(non_camel_case_types)]
pub struct char;
#[allow(non_camel_case_types)]
pub struct f32;
#[allow(non_camel_case_types)]
pub struct ... | fim | yewstack/yew | rust |
<|fim_suffix|>iew(&self, _ctx: &::yew::Context<Self>) -> ::yew::Html {
::std::unimplemented!()
}
}
pub struct Fail;
fn main() {
let dyn_prop = || Fail;
_ = ::yew::html! { <span { Fail }={ "" } /> };
_ = ::yew::html! { <span { dyn_prop() }={ "" } /> };
_ = ::yew::html! { <Simple "test... | fim | yewstack/yew | rust |
#![no_implicit_prelude]
// Shadow primitives
#[allow(non_camel_case_types)]
pub struct bool;
#[allow(non_camel_case_types)]
pub struct char;
#[allow(non_camel_case_types)]
pub struct f32;
#[allow(non_camel_case_types)]
pub struct f64;
#[allow(non_camel_case_types)]
pub struct i128;
#[allow(non_camel_case_types)]
pub s... | fim | yewstack/yew | rust |
<|fim_suffix|>put onclick=1 /> };
html! { <input onclick={Callback::from(|a: String| ())} /> };
html! { <input onfocus={Some(5)} /> };
// NodeRef type mismatch
html! { <input ref={()} /> };
html! { <input ref={Some(NodeRef::default())} /> };
html! { <input onclick={Callback::from(|a: String| ()... | fim | yewstack/yew | rust |
<|fim_suffix|>or _ in 0 .. 10 {
<div key={smth::KEY} />
}};
}
<|fim_prefix|>mod smth {
const KEY: u32 = 42;
}
fn main() {
_ = ::yew::html!{for x};
_ = ::yew::html!{for x in};
_ = ::yew::html!{for x in 0 .. 10};
_ = ::yew::html!{for (x, y) in 0 .. 10 {
<span>{x}</span>
<|fim_mi... | fim | yewstack/yew | rust |
<|fim_suffix|>n_value_from_preamble();
// `return` with a value in unbraced match arm (value part of ExprReturn).
fn return_value_from_unbraced_arm() -> ::std::primitive::i32 {
_ = ::yew::html!{
for i in 0..10 {
match i {
3 => return i,
... | fim | yewstack/yew | rust |
<|fim_prefix|>use std::marker::PhantomData;
use yew::prelude::*;
pub struct Generic<T> {
marker: PhantomData<T>,
}
impl<T> Component for Generic<T>
where
T: 'static,
{
type Message = ();
type Properties = ();
fn create(_ctx: &Context<Self>) -> Self {
unimplemented!()
}
fn view(&se... | fim | yewstack/yew | rust |
<|fim_prefix|>#![no_implicit_prelude]
// Shadow primitives
#[allow(non_camel_case_types)]
pub struct bool;
#[allow(non_camel_case_types)]
pub struct char;
#[allow(non_camel_case_types)]
pub struct f32;
#[allow(non_camel_case_types)]
pub struct f64;
#[allow(non_camel_case_types)]
pub struct i128;
#[allow(non_camel_case... | fim | yewstack/yew | rust |
<|fim_suffix|> opt_none: ::std::option::Option<::std::string::String> = ::std::option::Option::None;
_ = ::yew::html! { <div>{opt_none}</div> };
let num = 42i32;
_ = ::yew::html! { <div>{&num}</div> };
let text = ::std::string::String::new();
_ = ::yew::html! { <div>{&text}</div> };
let sr: &... | fim | yewstack/yew | rust |
<|fim_prefix|>use yew::prelude::*;
fn compile_fail() {
html! { if {} };
html! { if 42 {} };
html! { if tr<|fim_suffix|>ue {} else };
}
fn main() {}
<|fim_middle|>ue {} else };
html! { if true {} else if {} };
html! { if true {} else if true {} else };
html! { if true {} else if tr<|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>#![no_implicit_prelude]
fn compile_pass_lit() {
_ = ::yew::html! { if true {} };
_ = ::yew::html! { if true { <div/> } };
_ = ::yew::html! { if true { <div/><div/> } };
_ = ::yew::html! { if true { <div/><div/> } };
_ = ::yew::html! { if true {} else {} };
_ = ::yew::html! { if tr... | fim | yewstack/yew | rust |
<|fim_suffix|>
let _ = html! {
for _ in 0..1 {
match () {
() => break <div/>
}
}
};
}
<|fim_prefix|>use yew::prelude::*;
fn main() {
// Missing scrutinee
html! { match {} };
// Missing body
html! { match 42 };
// E<|fim_middle|>mpty ... | fim | yewstack/yew | rust |
<|fim_prefix|>#![no_implicit_prelude]
// Shadow primitives
#[allow(non_camel_case_types)]
pub struct bool;
#[allow(non_camel_case_types)]
pub struct char;
#[allow(non_camel_case_types)]
pub struct f32;
#[allow(non_camel_case_types)]
pub struct f64;
#[allow(non_camel_case_types)]
pub struct i128;
#[allow(non_camel_case... | fim | yewstack/yew | rust |
<|fim_suffix|>_camel_case_types)]
pub struct usize;
fn compile_pass() {
_ = ::yew::html! { "" };
_ = ::yew::html! { 'a' };
_ = ::yew::html! { "hello" };
_ = ::yew::html! { 42 };
_ = ::yew::html! { 1.234 };
_ = ::yew::html! { <span>{ "" }</span> };
_ = ::yew::html! { <span>{ 'a' }</span> };... | fim | yewstack/yew | rust |
<|fim_prefix|>// Imperative `for`, `while`, and `loop` blocks in preamble position are
// detected as Rust statements when the entire expression is Rust-parseable
// (no html elements anywhere inside). The user does not need to add a
// trailing `;` or wrap the loop in `let _ = ...;`.
fn main() {
// Imperative `fo... | fim | yewstack/yew | rust |
use yew::prelude::*;
fn compile_fail() {
html! { for };
html! { for () };
html! { {for ()} };
html! { for Vec::<()>::new().into_iter() };
let empty = Vec::<()>::new().into_iter();
html! { for empty };
let empty = Vec::<()>::new();
html! { {for empty.iter()} };
html! {
<di... | fim | yewstack/yew | rust |
<|fim_suffix|>u16;
#[allow(non_camel_case_types)]
pub struct u32;
#[allow(non_camel_case_types)]
pub struct u64;
#[allow(non_camel_case_types)]
pub struct u8;
#[allow(non_camel_case_types)]
pub struct usize;
fn empty_vec() -> ::std::vec::Vec<::yew::Html> {
::std::vec::Vec::<::yew::Html>::new()
}
fn empty_iter() -... | fim | yewstack/yew | rust |
<|fim_suffix|> // invalid prop
html! { <some_attr="test"></> };
}
fn main() {}
<|fim_prefix|>use yew::prelude::*;
fn compile_fail() {
// missing closing tag
html! { <> };
html! { <><<|fim_middle|>> };
html! { <><></> };
// missing starting tag
html! { </> };
html! { </></> };
... | fim | yewstack/yew | rust |
<|fim_prefix|>#![no_i<|fim_suffix|> are still allowed
_ = ::yew::html! {
<key={::std::string::ToString::to_string("key")}>
</>
};
// nested fragments as children of another fragment are still allowed
_ = ::yew::html! {
<key="outer">
<></>
<></>
</>... | fim | yewstack/yew | rust |
<|fim_suffix|> u32,
}
#[component]
pub fn Foo(_props: &FooProps) -> Html {
html! {}
}
fn main() {}<|fim_prefix|>us<|fim_middle|>e yew::prelude::*;
#[component]
pub fn App() -> Html {
html! {
<Foo />
}
}
#[component]
pub fn App1() -> Html {
html! {
<Foo bar={"bar".to_string()} />
... | fim | yewstack/yew | rust |
<|fim_prefix|>#![no_implicit_prelude]
fn main() {
// multi-root with elements
_ = ::yew::html! {
<span>{ "a" }</span>
<span>{ "b" }</span>
};
// multi-root with mixed literal and element
_ = ::yew::html! {
"prefix"
<span>{ "b" }</span>
};
// multi-root with... | fim | yewstack/yew | rust |
<|fim_prefix|>#![allow(uncommon_codepoints)]
use yew::prelude::*;
fn compile_fail() {
html! { <span>{ "v<|fim_suffix|>s
html! { b'a' };
html! { b"str" };
html! { <span>{ b'a' }</span> };
html! { <span>{ b"str" }</span> };
let not_node = || ();
html! {
not_node()
};
htm... | fim | yewstack/yew | rust |
#![no_implicit_prelude]
// Shadow primitives
#[allow(non_camel_case_types)]
pub struct bool;
#[allow(non_camel_case_types)]
pub struct char;
#[allow(non_camel_case_types)]
pub struct f32;
#[allow(non_camel_case_types)]
pub struct f64;
#[allow(non_camel_case_types)]
pub struct i128;
#[allow(non_camel_case_types)]
pub s... | fim | yewstack/yew | rust |
<|fim_suffix|>ring::String::from("world");
let _ = ::yew::html! { <Text>{s}</Text> };
let _ = ::yew::html! { <Text>{ ::std::format!("year {}", 2024) }</Text> };
let status: ::std::option::Option<::std::string::String> =
::std::option::Option::Some("Active".into());
let _ = ::yew::html! {
... | fim | yewstack/yew | rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.