CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 14:21:43 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=66e240c65163a7f4da1c62d1c6965569b2c51909f07733b438712829bb82e35da%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22jQ6bck8_FYapJ_xYocrrhAkAqzsoHoLs%22%3B%7D; HttpOnly; Path=/
cf-ray: 98cf016a6cfeea32-BLR
Clases en Rust ejemplo Super Trait e impl - Pastebin.com
SHARE
TWEET

Clases en Rust ejemplo Super Trait e impl
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Ejemmplo de clase en Rust Super trait e impl
- */
- #[warn(dead_code)]
- //#[derive(Debug)]
- //Numero de patas
- trait Animal{
- fn numero_patas(&self) -> u32;
- }
- //Nombre
- trait Mascota:Animal{
- fn nombre(&self) ->String;
- }
- struct Perro (String);
- //Perro implementa Animal y mascota
- impl Animal for Perro{
- fn numero_patas(&self) ->u32{
- 4
- }
- }
- impl Mascota for Perro{
- fn nombre(&self) ->String{
- self.0.clone()
- }
- }
- fn main (){
- let mascota1 =Perro(String::from ("Bongo"));
- let mascota2 = Perro(String::from ("Dana"));
- println! ("{} tiene {} patas ",mascota1.nombre(),mascota1.numero_patas());
- println! ("{} tiene {} patas ",mascota2.nombre(),mascota2.numero_patas());
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐✅ MAKE $2500 IN 15 MIN⭐⭐⭐ 6
JavaScript | 7 sec ago | 0.24 KB
-
⭐⭐⭐Make $15OO in 2O minutesV E⭐⭐
Java | 9 sec ago | 0.10 KB
-
⭐⭐⭐Profit Method⭐⭐
Java | 10 sec ago | 0.10 KB
-
⭐ Instant BTC Profit Method ✅ NEVER SEEN BEFO...
JavaScript | 15 sec ago | 0.24 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ 3
JavaScript | 19 sec ago | 0.24 KB
-
⭐⭐⭐Instant Profit Method⭐⭐
Java | 20 sec ago | 0.10 KB
-
⭐⭐⭐MAKE $9OO INSTANTLY D A⭐⭐
Java | 22 sec ago | 0.10 KB
-
⭐✅ MAKE $2000 INSTANTLY ✅ NEVER SEEN BEFORE ⭐...
JavaScript | 27 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand