Created
January 26, 2024 02:57
-
-
Save gusdelact/01a1a5eee75e1a2fff312b45f8bd43a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://play.rust-lang.org | |
https://t.me/RustMX | |
*/ | |
fn f1( p0:i32) -> i32 | |
{ | |
let p1 = p0 +1; | |
p1*2 | |
} | |
fn f1_1(mut p0:i32) -> i32 | |
{ | |
println!("{:p}",&p0); | |
p0 = p0 +10; | |
p0*5 | |
} | |
fn f2(mut s:String) | |
{ | |
println!("{:p}",&s); | |
s.push('c'); | |
println!("{}",s); | |
} | |
fn f2_1(mut s:String) -> String | |
{ | |
s.push('z'); | |
s | |
} | |
fn f3(s: &mut String) | |
{ | |
println!("{:p}",s); | |
s.push('2'); | |
println!("{}",s); | |
} | |
#[derive(Debug)] | |
struct Estr01 | |
{ | |
a: i32, | |
b: char, | |
fl: bool, | |
s: String | |
} | |
fn main() | |
{ | |
let x = 1; | |
let mut x0 = x +1; | |
x0 = x0 + 2 + x; | |
println!("{} {}",x0,x); | |
let cadena:String ; | |
cadena = String::from("hola mundo Rust"); | |
println!("{}",cadena); | |
let mut cadena2 = String::from("esto no es Java"); | |
let real = 3.14f32; | |
println!("{}",2.0*real); | |
let x1=f1(x); | |
println!("{}",x1); | |
println!("{}",f1_1(x1)); | |
println!("{}",x1); | |
println!("{:p}",&x1); | |
println!("{:p}",&cadena2); | |
f2(cadena2.clone()); | |
//cadena2.push('d'); | |
println!("{}",cadena2); | |
let mut cadena2_1 = f2_1(cadena2); | |
cadena2_1.push('w'); | |
println!("{}",cadena2_1); | |
let mut cadena3 = String::from("hola referencias"); | |
println!("{:p}",&cadena3); | |
f3(&mut cadena3); | |
cadena3.push('!'); | |
println!("{}",cadena3); | |
let mut es01= Estr01{a:5,b:'w',fl:true,s:String::from("de es01")}; | |
es01.a=10; es01.b='x'; | |
println!("{:?}",es01); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment