rust-for-kotlin-devs

(★ 52)

A complete Rust language guide for Kotlin developers — side-by-side comparisons, idiom cheat sheet, 7-day plan, and runnable examples.

파일 탐색기

  • .gitignore
  • Cargo.toml
  • LICENSE
  • README.md

# CDN으로 사용하기

jsDelivr

jsDelivr는 공개 GitHub 리포지토리를 별도 설정 없이 CDN으로 즉시 서빙합니다. 버전과 파일을 고르면 웹페이지에 바로 붙일 수 있는 링크와 예시 코드가 만들어집니다.

명령어 용어집

이 문서에서 사용된 명령어를 모아봤습니다. 낯선 명령어가 있다면 펼쳐서 확인해보세요.

🔍

interface

설명 보기 ▼

인터페이스를 관리.
설정 모드에서 사용함.
더 많은 정보: <https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/interface/command/ir-cr-book/ir-i1.html>.

interface vlan {{1}}

VLAN 인터페이스 설정:

{{no shutdown|shutdown}}

인터페이스 활성화 또는 비활성화 (interface 명령 내부에서 실행):

🔍

cargo add

설명 보기 ▼

Add dependencies to a Rust project's `Cargo.toml` manifest.

cargo add {{dependency}}

Add the latest version of a dependency to the current project:

cargo add {{dependency}}@{{version}}

Add a specific version of a dependency:

cargo add {{dependency}} {{[-F|--features]}} {{feature_1,feature_2,...}}

Add a dependency and enable one or more specific features:

🔍

cargo build

설명 보기 ▼

Compile a local package and all of its dependencies.

cargo {{[b|build]}}

Build the package or packages defined by the `Cargo.toml` manifest file in the local path:

cargo {{[b|build]}} {{[-r|--release]}}

Build artifacts in release mode, with optimizations:

cargo {{[b|build]}} --locked

Require that `Cargo.lock` is up to date:

🔍

cargo check

설명 보기 ▼

Check a local package and all of its dependencies for errors.

cargo {{[c|check]}}

Check the current package:

cargo {{[c|check]}} --tests

Check all tests:

cargo {{[c|check]}} --test {{integration_test1}}

Check the integration tests in `tests/integration_test1.rs`:

🔍

cargo clippy

설명 보기 ▼

A collection of lints to catch common mistakes and improve your Rust code.

cargo clippy

Run checks over the code in the current directory:

cargo clippy --locked

Require that `Cargo.lock` is up to date:

cargo clippy --workspace

Run checks on all packages in the workspace:

🔍

cargo doc

설명 보기 ▼

Build the documentation of Rust packages.

cargo {{[d|doc]}}

Build the documentation for the current project and all dependencies:

cargo {{[d|doc]}} --no-deps

Do not build documentation for dependencies:

cargo {{[d|doc]}} --open

Build and open the documentation in a browser:

🔍

cargo fmt

설명 보기 ▼

Run `rustfmt` on all source files in a Rust project.
See also: `rustfmt`.

cargo fmt

Format all source files:

cargo fmt --check

Check for formatting errors without writing to the files:

cargo fmt -- {{rustfmt_args}}

Pass arguments to each `rustfmt` call:

🔍

cargo new

설명 보기 ▼

Create a new Cargo package.
Equivalent of `cargo init`, but specifying a directory is required.

cargo new {{path/to/directory}}

Create a new Rust project with a binary target:

🔍

cargo run

설명 보기 ▼

Run the current Cargo package.
Note: The working directory of the executed binary will be set to the current working directory.

cargo {{[r|run]}}

Run the default binary target:

cargo {{[r|run]}} --bin {{name}}

Run the specified binary:

cargo {{[r|run]}} --example {{name}}

Run the specified example:

🔍

cargo test

설명 보기 ▼

Execute the unit and integration tests of a Rust package.

cargo {{[t|test]}} {{test_name}}

Only run tests containing a specific string in their names:

cargo {{[t|test]}} -- --test-threads {{count}}

Set the number of simultaneous running test cases:

cargo {{[t|test]}} {{[-r|--release]}}

Test artifacts in release mode, with optimizations:

🔍

fold

설명 보기 ▼

지정된 너비에 맞게 입력 파일의 각 줄을 감싸고 `stdout`으로 출력.
더 많은 정보: <https://manned.org/fold.1p>.

fold {{path/to/file}}

각 줄을 기본 너비로 변경 (80 자):

fold {{[-w|--width]}} {{width}} {{path/to/file}}

고정 폭으로 줄을 접기:

fold -w30 {{path/to/file}}

각 줄을 너비 "30"으로 줄 바꿈:

🔍

gradle init

설명 보기 ▼

Initialize a new Gradle project interactively.

gradle init

Initialize a new Gradle project interactively:

gradle init --type {{basic|java-application|java-library|...}}

Initialize a project of a specific type:

gradle init --dsl {{groovy|kotlin}}

Initialize a project with a specific DSL:

🔍

join

설명 보기 ▼

두 정렬된 파일의 공통 필드를 기준으로 줄을 결합.
더 많은 정보: <https://www.gnu.org/software/coreutils/manual/html_node/join-invocation.html>.

join {{path/to/file1}} {{path/to/file2}}

기본 필드(첫 번째 필드)를 기준으로 두 파일 결합:

join -t ',' {{path/to/file1}} {{path/to/file2}}

쉼표(공백 대신)를 필드 구분자로 사용하여 두 파일 결합:

join -1 {{3}} -2 {{1}} {{path/to/file1}} {{path/to/file2}}

파일1의 필드3과 파일2의 필드1을 기준으로 결합:

🔍

rustfmt

설명 보기 ▼

Rust 소스 코드를 포맷합니다.
더 많은 정보: <https://github.com/rust-lang/rustfmt>.

rustfmt {{path/to/source.rs}}

파일을 포맷하여 원본 파일을 덮어쓰기:

rustfmt --check {{path/to/source.rs}}

파일의 포맷을 확인하고 변경 사항을 콘솔에 표시:

rustfmt --backup {{path/to/source.rs}}

포맷하기 전에 변경된 파일을 백업 (원본 파일은 `.bk` 확장자로 이름이 변경됩니다):

🔍

rustup

설명 보기 ▼

Rust 툴체인을 설치, 관리 및 업데이트.
`toolchain`, `target`, `update` 등의 일부 하위 명령에는 자체 사용 설명서가 있습니다.
더 많은 정보: <https://rust-lang.github.io/rustup/>.

rustup install nightly

시스템에 nightly 툴체인 설치:

rustup default nightly

기본 툴체인을 nightly로 전환하여 `cargo` 및 `rustc` 명령이 이를 사용하도록 설정:

rustup override set nightly

현재 프로젝트 내에서만 nightly 툴체인을 사용하고 전역 설정은 변경하지 않음:

🔍

select

설명 보기 ▼

메뉴를 생성하기 위한 Bash 내장 구조.
더 많은 정보: <https://www.gnu.org/software/bash/manual/bash.html#index-select>.

select {{word}} in {{apple orange pear banana}}; do echo ${{word}}; done

개별 단어로 메뉴 생성:

select {{line}} in $({{command}}); do echo ${{line}}; done

다른 명령의 출력으로 메뉴 생성:

PS3="{{Select a file: }}"; select {{file}} in *; do echo ${{file}}; done

`select`의 프롬프트 문자열을 지정하고 현재 디렉토리에서 파일이나 폴더를 선택하는 메뉴 생성:

🔍

sum

설명 보기 ▼

파일의 체크섬과 블록 수를 계산.
더 현대적인 `cksum`의 전신.
더 많은 정보: <https://www.gnu.org/software/coreutils/manual/html_node/sum-invocation.html>.

sum {{path/to/file}}

BSD 호환 알고리즘과 1024바이트 블록으로 체크섬 계산:

sum {{[-s|--sysv]}} {{path/to/file}}

System V 호환 알고리즘과 512바이트 블록으로 체크섬 계산:

🔍

suspend

설명 보기 ▼

현재 쉘의 실행을 일시 중지.
더 많은 정보: <https://www.gnu.org/software/bash/manual/bash.html#index-suspend>.

{{bash}} <Enter> suspend

현재 쉘 일시 중지 (`su`와 같이 중첩된 쉘에서 유용):

pkill -CONT {{bash}}

중첩되지 않은 쉘에서 `suspend`를 사용한 경우, 별도의 터미널에서 실행을 재개:

suspend -f

시스템에 다시 접근할 수 없게 될 수 있는 경우에도, 강제로 쉘 일시 중지:

🔍

where

설명 보기 ▼

명령의 모든 알려진 인스턴스를 보고.
이는 `$PATH` 환경 변수에 있는 실행 파일, 별칭 또는 셸 내장 명령일 수 있습니다.
더 많은 정보: <https://zsh.sourceforge.io/Doc/Release/Shell-Builtin-Commands.html>.

where {{command}}

명령의 모든 인스턴스 찾기:

tldr where-object

파일 패턴의 위치 표시:

where {{file_pattern}}

파일 크기와 날짜를 포함하여 파일 패턴의 위치 표시:

🔍

copy

설명 보기 ▼

파일을 복사하는 명령어.
더 많은 정보: <https://www.dosbox.com/wiki/Commands#COPY>.

COPY {{path/to/source_file}} {{path/to/destination_file}}

파일 복사:

🔍

move

설명 보기 ▼

파일 및 디렉토리를 이동 또는 이름을 변경합니다.
PowerShell에서 이 명령어는 `Move-Item`의 별칭입니다. 이 문서는 `move`의 Command Prompt (`cmd`) 버전을 기준으로 작성되었습니다.
더 많은 정보: <https://learn.microsoft.com/windows-server/administration/windows-commands/move>.

tldr move-item

동등한 PowerShell 명령어 문서 보기:

move {{path\to\source}} {{path\to\target}}

목표가 기존 디렉토리가 아닐 때 파일 또는 디렉토리 이름 변경:

move {{path\to\source}} {{path\to\existing_directory}}

파일 또는 디렉토리를 기존 디렉토리로 이동:

// repository documentation