2024-06-21
This commit is contained in:
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# 디폴트 무시된 파일
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
6
.idea/copyright/Elex_Project.xml
generated
Normal file
6
.idea/copyright/Elex_Project.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<component name="CopyrightManager">
|
||||||
|
<copyright>
|
||||||
|
<option name="notice" value="Copyright (c) &#36;originalComment.match("Copyright \(c\) (\d+)", 1, "-", "&#36;today.year")&#36;today.year. Elex. All Rights Reesrved. https://www.elex-project.com/" />
|
||||||
|
<option name="myName" value="Elex Project" />
|
||||||
|
</copyright>
|
||||||
|
</component>
|
||||||
7
.idea/copyright/profiles_settings.xml
generated
Normal file
7
.idea/copyright/profiles_settings.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<component name="CopyrightManager">
|
||||||
|
<settings>
|
||||||
|
<module2copyright>
|
||||||
|
<element module="Project Files" copyright="Elex Project" />
|
||||||
|
</module2copyright>
|
||||||
|
</settings>
|
||||||
|
</component>
|
||||||
6
Writerside/c.list
Normal file
6
Writerside/c.list
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE categories
|
||||||
|
SYSTEM "https://resources.jetbrains.com/writerside/1.0/categories.dtd">
|
||||||
|
<categories>
|
||||||
|
<category id="wrs" name="Writerside documentation" order="1"/>
|
||||||
|
</categories>
|
||||||
17
Writerside/cfg/buildprofiles.xml
Normal file
17
Writerside/cfg/buildprofiles.xml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2024. Elex. All Rights Reesrved.
|
||||||
|
~ https://www.elex-project.com/
|
||||||
|
-->
|
||||||
|
|
||||||
|
<buildprofiles xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/build-profiles.xsd"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
|
||||||
|
<variables></variables>
|
||||||
|
<build-profile instance="r">
|
||||||
|
<variables>
|
||||||
|
<noindex-content>true</noindex-content>
|
||||||
|
</variables>
|
||||||
|
</build-profile>
|
||||||
|
|
||||||
|
</buildprofiles>
|
||||||
BIN
Writerside/images/completion_procedure.png
Normal file
BIN
Writerside/images/completion_procedure.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 125 KiB |
BIN
Writerside/images/completion_procedure_dark.png
Normal file
BIN
Writerside/images/completion_procedure_dark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
BIN
Writerside/images/convert_table_to_xml.png
Normal file
BIN
Writerside/images/convert_table_to_xml.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 341 KiB |
BIN
Writerside/images/convert_table_to_xml_dark.png
Normal file
BIN
Writerside/images/convert_table_to_xml_dark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 119 KiB |
BIN
Writerside/images/new_topic_options.png
Normal file
BIN
Writerside/images/new_topic_options.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 306 KiB |
BIN
Writerside/images/new_topic_options_dark.png
Normal file
BIN
Writerside/images/new_topic_options_dark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 274 KiB |
18
Writerside/r.tree
Normal file
18
Writerside/r.tree
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
- Copyright (c) 2024. Elex. All Rights Reesrved.
|
||||||
|
- https://www.elex-project.com/
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!DOCTYPE instance-profile
|
||||||
|
SYSTEM "https://resources.jetbrains.com/writerside/1.0/product-profile.dtd">
|
||||||
|
|
||||||
|
<instance-profile id="r"
|
||||||
|
name="Rust"
|
||||||
|
start-page="starter-topic.md">
|
||||||
|
|
||||||
|
<toc-element topic="starter-topic.md">
|
||||||
|
<toc-element topic="Variable.md"/>
|
||||||
|
<toc-element topic="Function.md"/>
|
||||||
|
</toc-element>
|
||||||
|
</instance-profile>
|
||||||
1
Writerside/topics/Function.md
Normal file
1
Writerside/topics/Function.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 함수
|
||||||
76
Writerside/topics/Variable.md
Normal file
76
Writerside/topics/Variable.md
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
# 변수
|
||||||
|
|
||||||
|
## 선언
|
||||||
|
|
||||||
|
```rust
|
||||||
|
let x: i32 = 100;
|
||||||
|
```
|
||||||
|
|
||||||
|
러스트에서는 `let`을 사용해서 변수를 선언 합니다. 변수명 뒤에는 `:`과 함께 자료형을 명시합니다.
|
||||||
|
|
||||||
|
## 불변성
|
||||||
|
|
||||||
|
러스트의 변수는 기본적으로 불변(immutable)입니다. 그래서, 한 번 할당된 변수에 새로운 값을 다시 할당할 수는 없습니다.
|
||||||
|
|
||||||
|
```rust
|
||||||
|
let x = 100;
|
||||||
|
x = 0; // Compile Error!
|
||||||
|
```
|
||||||
|
|
||||||
|
값이 바뀌어야 하는(mutable) 변수를 선언하려면, `mut`를 사용합니다.
|
||||||
|
|
||||||
|
```rust
|
||||||
|
let mut x = 100;
|
||||||
|
```
|
||||||
|
|
||||||
|
## 새도잉
|
||||||
|
|
||||||
|
불변 변수에 값을 할당하는 것은 불가능하지만, 같은 이름으로 다시 변수를 선언하는 것은 가능합니다. 이를 shadowing이라고 부릅니다.
|
||||||
|
|
||||||
|
```rust
|
||||||
|
let x = 100;
|
||||||
|
let x = 5;
|
||||||
|
```
|
||||||
|
|
||||||
|
## 자료형
|
||||||
|
|
||||||
|
러스트에는 다음과 같은 원시 자료형이 존재합니다.
|
||||||
|
|
||||||
|
- i8, i16, i32, i64, i128, isize
|
||||||
|
|
||||||
|
- u8, u16, u32, u64, u128, usize
|
||||||
|
|
||||||
|
- f32, f64
|
||||||
|
|
||||||
|
- bool
|
||||||
|
|
||||||
|
- String, str
|
||||||
|
|
||||||
|
|
||||||
|
isize와 usize는 CPU의 아키텍쳐에 따라 크기가 달라지는 자료형입니다.
|
||||||
|
|
||||||
|
## 타입 추론
|
||||||
|
|
||||||
|
변수명 뒤에 자료형을 생략해도 컴파일러가 자료형을 추론합니다.
|
||||||
|
|
||||||
|
```rust
|
||||||
|
let x = 1; // i32
|
||||||
|
let y = 1.0; // f64
|
||||||
|
```
|
||||||
|
|
||||||
|
## 형 변환
|
||||||
|
|
||||||
|
러스트에서 형 변환은 `as`를 사용합니다.
|
||||||
|
|
||||||
|
```rust
|
||||||
|
let x: f64 = 3.14;
|
||||||
|
let y = x as i32;
|
||||||
|
```
|
||||||
|
|
||||||
|
## 상수
|
||||||
|
|
||||||
|
러스트에서 상수는 `const`를 사용해서 선언합니다.
|
||||||
|
|
||||||
|
```rust
|
||||||
|
const MY_VALUE: i32 = 100;
|
||||||
|
```
|
||||||
96
Writerside/topics/starter-topic.md
Normal file
96
Writerside/topics/starter-topic.md
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
# Rust
|
||||||
|
|
||||||
|
## rustup
|
||||||
|
|
||||||
|
먼저, 러스트 툴체인 인스톨러를 설치합니다.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo snap install rustup --classic
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rustup -V # 버전 확인
|
||||||
|
```
|
||||||
|
|
||||||
|
RustUp을 통해서 Rust를 설치합니다.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rustup install stable
|
||||||
|
rustup default stable
|
||||||
|
```
|
||||||
|
|
||||||
|
또는
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## 프로젝트 생성
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir my_project
|
||||||
|
cd my_project
|
||||||
|
cargo init
|
||||||
|
```
|
||||||
|
|
||||||
|
또는,
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo new my_project
|
||||||
|
```
|
||||||
|
|
||||||
|
위 명령을 실행하면 프로젝트 폴더에 'Cargo.toml' 과 'src/main.rs' 등의 파일이 생성됩니다.
|
||||||
|
|
||||||
|
### Hello, world!
|
||||||
|
|
||||||
|
위에서 생성된 main.rs 파일은 간단한 헬로 월드 프로그램입니다.
|
||||||
|
|
||||||
|
```rust
|
||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
`println`은 화면에 한 줄 출력하는 매크로입니다. 러스트에서는 매크로 이름 뒤에 `!`가 붙습니다.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo build
|
||||||
|
```
|
||||||
|
|
||||||
|
`./target/debug` 디렉토리에 실행 파일이 만들어집니다. 다음 명령으로 프로그램을 실행시키면 화면에 'Hello, world!'가 출력됩니다.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./target/debug/my_project
|
||||||
|
```
|
||||||
|
|
||||||
|
배포용으로 컴파일하려면, release 옵션을 추가합니다.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo build --release
|
||||||
|
```
|
||||||
|
|
||||||
|
`cargo run` 명령을 사용하면 빌드와 동시에 실행할 수 있습니다.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo run
|
||||||
|
```
|
||||||
|
|
||||||
|
또는,
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo run --release
|
||||||
|
```
|
||||||
|
|
||||||
|
## rustfmt
|
||||||
|
|
||||||
|
소스 코드를 깔끔하게 정리해 줍니다.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rustfmt ./src/main.rs
|
||||||
|
```
|
||||||
|
|
||||||
|
또는, 아래 명령으로 전체 소스 파일에 대해 처리할 수 있습니다.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo fmt
|
||||||
|
```
|
||||||
5
Writerside/v.list
Normal file
5
Writerside/v.list
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE vars SYSTEM "https://resources.jetbrains.com/writerside/1.0/vars.dtd">
|
||||||
|
<vars>
|
||||||
|
<var name="product" value="Writerside"/>
|
||||||
|
</vars>
|
||||||
13
Writerside/writerside.cfg
Normal file
13
Writerside/writerside.cfg
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
- Copyright (c) 2024. Elex. All Rights Reesrved.
|
||||||
|
- https://www.elex-project.com/
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!DOCTYPE ihp SYSTEM "https://resources.jetbrains.com/writerside/1.0/ihp.dtd">
|
||||||
|
|
||||||
|
<ihp version="2.0">
|
||||||
|
<topics dir="topics" web-path="topics"/>
|
||||||
|
<images dir="images" web-path="images"/>
|
||||||
|
<instance src="r.tree"/>
|
||||||
|
</ihp>
|
||||||
Reference in New Issue
Block a user