use std::io; use tl_build::parse_tl_file; use tl_build::tl::Definition; use tl_build::{generate_rust_code, Config}; const LAYER: i32 = 0; fn get_definitions(contents: &str) -> Vec { parse_tl_file(&contents) .into_iter() .map(|d| d.unwrap()) .collect() } #[test] fn generic_functions_use_generic_parameters() -> io::Result<()> { let definitions = get_definitions( " ---functions--- invokeWithLayer#da9b0d0d {X:Type} layer:int query:!X = X; ", ); let mut file = Vec::new(); generate_rust_code( &mut file, &definitions, LAYER, &Config { gen_name_for_id: false, deserializable_functions: true, impl_debug: true, impl_from_enum: true, impl_from_type: true, }, )?; let result = String::from_utf8(file).unwrap(); eprintln!("{}", result); assert!(result.contains("InvokeWithLayer")); assert!(result.contains("pub query: X,")); assert!(result .contains("impl tl_types::Identifiable for InvokeWithLayer")); assert!(result .contains("impl tl_types::Serializable for InvokeWithLayer")); assert!(result .contains("impl tl_types::Deserializable for InvokeWithLayer")); assert!(result .contains("impl tl_types::RemoteCall for InvokeWithLayer")); assert!(result.contains("type Return = X::Return;")); Ok(()) }