Rust
11 TopicsRust Learners - Matchmaking
Hey Everyone, Thanks for joining the Getting Started with Rust workshops! The interest in Rust is incredible. In order to help learners find other learners that are at the same skill level, geographic area and maybe even previous programming experience, I have created this thread. Feel free to post and contact others that you would like to learn Rust with. I will start with my own: Name: Korey Experience with Rust: Advanced Beginner Previous Programming Experience: Python (AI/ML), Javascript Where to Contact Me: Twitter - @koreyspace LinkedIn: /koreyspace3.2KViews0likes20CommentsEjercicio: Dibujar círculos con macroquad
Primeros Pasos con Rust Hola compañeros, si tienen un tiempo libre podrían ayudarme a terminar este corto programa con macroquad. El objetivo es dibujar en varios círculos de radio aleatorio en filas sin exceder las dimensiones de la pantalla. Para esto estoy creando un iterator personalizado que tiene en cuenta los últimos valores de radio y posiciones x e y generadas, y que trata de verificar que el círculo se pueda dibujar dentro del ancho y el alto de la ventana. Por el momento, mi programa dibuja los círculos en una diagonal. Creo que debo corregir el método next(). Gracias por su ayuda. cargo new shapes --vcs none [package] name = "shapes" version = "0.1.0" rust-version = "1.67" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] macroquad = "0.3" rand = "0.8" main.rs: use ::rand as ra; use macroquad::{color, prelude::*}; use ra::Rng; //use macroquad::rand::rand::prelude::*; /// Representa un objeto para ubicar un círculo en la pantalla. struct Posicionador { ultimo_r: f32, ultimo_x: f32, ultimo_y: f32, aleatorio: ra::rngs::ThreadRng, } impl Posicionador { /// Crea un nuevo objeto. fn new() -> Self { Self { ultimo_r: 0.0, ultimo_x: 0.0, ultimo_y: 0.0, aleatorio: ra::thread_rng(), } } } // Un iterador para crear varios círculos impl Iterator for Posicionador { type Item = Circulo; fn next(&mut self) -> Option<Self::Item> { // Espacio entre los círculos let espacio: f32 = 15.0; // Crear un radio aleatorio let nuevo_radio: f32 = self.aleatorio.gen_range(20..101) as f32; // Verificar que las dimensiones del círculo no sobrepasen las dimensiones de la ventana if (nuevo_radio + self.ultimo_x > screen_width()) || (nuevo_radio + self.ultimo_y > screen_height()) { // Aquí un círculo ya no cabe en la pantalla, por lo que terminamos el iterador return None; } // Actualizar los valores para el recién círculo creado self.ultimo_r = nuevo_radio; self.ultimo_x += nuevo_radio + espacio; self.ultimo_y += nuevo_radio + espacio; // Retornar el círculo pedido Some(Circulo { radio: self.ultimo_r, color: color::GOLD, posicion: Punto { x: self.ultimo_x, y: self.ultimo_y, }, }) } } /// Representa la ubicación x e y de un círculo. #[derive(Debug, Clone)] struct Punto { x: f32, y: f32, } /// Representa un círculo geométrico. struct Circulo { radio: f32, color: macroquad::color::Color, posicion: Punto, } impl Circulo { /// Dibuja el círculo en la pantalla fn dibujar(&self) { draw_circle(self.posicion.x, self.posicion.y, self.radio, self.color); } } #[macroquad::main("Figuras")] async fn main() { // Iterador para crear los círculos let mut posicionador = Posicionador::new(); // Vector de círculos let mut circulos: Vec<Circulo> = vec![]; // Crear tantos círculos como el iterador permita. while let Some(circulo) = posicionador.next() { circulos.push(circulo); } loop { clear_background(LIGHTGRAY); // Dibujar los círculos generados for circulo in &circulos { circulo.dibujar(); } next_frame().await } }738Views2likes2CommentsUn programa RUST de ejemplo
Primeros Pasos con Rust Hola programadores Rust, ¿Qué cambios necesita este programa en Rust para ejecutarse exitosamente? struct Person { name: String, age: u8, genre: char, } fn main() { // Vector of family members let family: Vec<Person> = Vec::new(); family.push(Person { name: "Frank".to_string(), age: 23, genre: 'M', }); family.push(Person { name: "Carol".to_string(), age: 25, genre: 'F', }); family.push(Person { name: "Edwin".to_string(), age: 34, genre: 'M', }); // Show current info println!("-".repeat(50)); for individual in family { println!("{:?}", individual); } // Add family lastname for member in family { member.name = member.name + "Thompson"; } // Increase age by 2 for adult in family { adult.age += 2; } // Show updated info println!("-".repeat(50)); for individual in family { match individual { 'M' => { println!("{} is a man {} years old", individual.name, individual.age); } 'F' => { println!( "{} is a woman {} years old", individual.name, individual.age ); } } } } #rustlang #programming1.1KViews1like2CommentsRust Learners LATAM - Matchmaking
Buenas, ¡Gracias por unirse a los talleres Primeros Pasos con Rust! El interés en Rust es increíble. Con el fin de ayudar a los estudiantes a encontrar otros estudiantes que tengan el mismo nivel de habilidad, área geográfica y tal vez incluso experiencia previa en programación, he creado este hilo. Siéntete libre de publicar y contactar a otras personas con las que te gustaría aprender Rust. Voy a empezar con la mía: Nombre: Bruno Capuano Experiencia con Rust: Principiante Avanzado Experiencia previa en programación: Python (AI/ML), C#, C++ Dónde contactarme: General - aka.ms/elbruno Twitter - @elbruno LinkedIn: /elbruno1.3KViews4likes3CommentsGetting Started With Rust: Rust Error Workshop Resources and Discussion
Hey Everyone, Thanks for checking out the Rust Error Workshop with myself and Ryan. Here are the resources shared earlier: Rust Learner Matchmaking Github Repo with Error Examples Handle Rust Errors Learn Module Ryan's Amazing Rust Youtube Channel Find Ryan Here: Twitter Find Korey Here: Twitter / LinkedIn388Views1like0CommentsUnderstanding Rust Compile Errors AMA
Hey Everyone, We will have Ryan Levick, Principal of Rust Developer Advocate at Microsoft, guide us through some through different levels of Rust Compile Errors tomorrow. If you have any questions for Ryan, please ask them here and we will make sure they get answered during the stream!404Views0likes0CommentsGetting Started with Rust: Getting Your First Rust Job AMA
Hey Everyone, We will have Marcus Grass speak at the Reactor on Wednesday, Nov. 2nd! He will talk about his journey working as a Java Developer to working now as a full-time Rust Developer at Embark Studios in Stockholm. He will share his tips and advice of moving from using Rust just as a "hobby" language to working with it professionally. If you have any questions for Marcus, please ask them here and we will make sure they get answered during the stream!1.6KViews0likes5CommentsGetting Started With Rust: Rust Basics Recap and Discussion
Hey Everyone, Thanks for joining the Rust Basics session earlier! Listed below are all the Rust resources we shared in the session. Let us know if you have any questions and please feel free to share your own resources you have found helpful on your own Rust learning journey! Session Links Session Recording Building Your First Rust Project Course Rust with VS Code Crates.Io What Can You Do With Rust Build a CLI App Tutorial Create a Rust function in Azure using Visual Studio Code Bevy Game Engine Rust and WASM wasm-pack wasmtime Learning Materials The Rust Book Rust Playground Rust User Forum Feel free to share any other great resources here and share any questions and challenges you have had on your Rust learning journey!1.1KViews4likes0Comments