본문 바로가기
반응형

IT/rust3

재미있는 문법 공부 출처 : 이지 러스트 1부 : 아래 소스는 오류 날것 같지만! 섀도잉 때문에 문제 없이 동작 한다.fn main() { let country = String::from("Korea"); let country_ref = &country; let country = 8; println!("{}, {}", country_ref, country);}//출력Korea, 8 소유권이 소멸되면서 아래는 오류가 나는 소스다!fn print_country(country_name: String) { println!("{}", country_name);}fn main() { let country = String::from("Korea"); print_country(country);.. 2025. 10. 10.
Rust 학습일지 - 예제 화씨-섭씨 변환 use std::io; fn main() { println!("화씨[F] 섭씨[C]:"); let mut input_value = String::new(); io::stdin().read_line(&mut input_value) .expect("입력실패"); println!("{}",input_value.to_string()); if input_value.trim().to_string() == "F" { println!("화씨온도를 입력하세요"); input_value = String::new(); io::stdin().read_line(&mut input_value) .expect("입력실패"); println!("{}",input_value); let input_value:u32 = .. 2021. 10. 3.
Rust 학습일지 - crate, mut, cargo, match cargo 명령어 프로젝트 생성 cargo new 프로젝트명 --bin 프로젝트 실행 cargo run 프로젝트 빌드 cargo build 프로젝트 업데이트 ( 의존성업데이트 ) cargo update 프로젝트 문서 오픈 : 사용한 의존 모듈의 메뉴얼을 웹페이지로 보여줌! cargo doc --open 의존성 모듈 삽입( crate == 나무상자 ) extern crate rand; 변수를 mutable == 변하기쉬운 에 mut 써서 표시 let guess // let 키워드를 써서 변경 ( shadow 라고 함 ) let mut guess //let 않쓰고 변경 const GUESS //상수 스위치와 비슷한 명령어 구문 match enum 리턴형 함수에 대해, 스위치 처리의 자동생성 이라고 이해중.... 2021. 10. 2.
반응형