Programming/Rust
[Rust] vscode 에 rust 설정
owls
2023. 2. 21. 17:21
728x90
vscode 설치는 아래 포스팅을 참고하면 됩니다~
Rust-analyzer 확장 모듈
Rust-Analyzer는 코드 자동 완성, 신텐스 하이라이팅, 정의 및 구현으로 이동, 코드 참조 검색 등 생산성을 높여 주는 각종 기능들을 제공하는 유용한 vscode확장 모듈입니다.
Rust-analyzer 확장 모듈 설치
프로젝트 생성
Ex1 프로젝트를 생성하기 위해 VSCode 터미널에 명령어를 입력합니다.
cargo new Ex1
PS C:\Users\ppoxox> cd e:
PS E:\vscode\rust> cd example
PS E:\vscode\rust\example> cargo new ex1
Created binary (application) `ex1` package
PS E:\vscode\rust\example> cd ex1
PS E:\vscode\rust\example\ex1> ls
디렉터리: E:\vscode\rust\example\ex1
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2023-02-21 오후 5:05 src
-a---- 2023-02-21 오후 5:05 8 .gitignore
-a---- 2023-02-21 오후 5:05 172 Cargo.toml
cargo에 의해 자동으로 생성되는 프로젝트 구성을 확인할 수 있습니다.
CodeLLDB 확장 모듈 설치
디버깅을 하기 위해 CodeLLDB 확장 모듈도 설치합니다.
launch.json
break point를 설정하고 디버깅을 실행하면 launch.json 생성 여부를 묻는 안내창이 나옵니다.
자동으로 launch.json이 생성됩니다.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'ex1'",
"cargo": {
"args": [
"build",
"--bin=ex1",
"--package=ex1"
],
"filter": {
"name": "ex1",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'ex1'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=ex1",
"--package=ex1"
],
"filter": {
"name": "ex1",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
이제 vscode에서 rust 프로젝트를 사용할 수 있습니다~
728x90