Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::clone::Clone;
- use std::fmt::Display;
- trait Cloneable: Clone + Display {}
- impl Cloneable for u32 {}
- struct ThingA<CloneableThisIsAGenericTypeParameterDeclaration> {
- val: CloneableThisIsAGenericTypeParameterDeclaration,
- }
- impl<CloneableThisIsAnotherGenericTypeParameterDeclaration: Cloneable> ThingA<CloneableThisIsAnotherGenericTypeParameterDeclaration> {
- pub fn new(val: CloneableThisIsAnotherGenericTypeParameterDeclaration) -> Self {
- Self {
- val,
- }
- }
- pub fn print(&self) {
- let c = self.val.clone();
- println!("{}", c);
- }
- }
- fn main() {
- println!("Hello, world!");
- let thing_a = ThingA::<u32>::new(42);
- thing_a.print();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement