Skip to content
Snippets Groups Projects
Commit 7541bb12 authored by Alfex4936's avatar Alfex4936
Browse files

Organize project

builders
parent 6bd131c2
No related branches found
No related tags found
No related merge requests found
Pipeline #5487 failed
Showing
with 3733 additions and 27 deletions
File moved
fast.py 0 → 100644
import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
app = FastAPI(title="Rust tutorial", description="Rust tutorial", version="1.0.0")
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_methods=["GET"],
allow_headers=["*"],
allow_credentials=True,
)
app.mount("/", StaticFiles(directory="public", html=True), name="static")
if __name__ == "__main__":
# standalone
uvicorn.run(app, host="0.0.0.0", port=8089, log_level="info")
module.exports = {
env: {
browser: true,
commonjs: true,
es2021: true,
node: true,
},
extends: [
'airbnb-base',
],
parserOptions: {
ecmaVersion: 12,
},
rules: {
},
};
lessons.json
docs/*.html
node_modules
.vscode
node_modules
\ No newline at end of file
# Use a smaller base image
FROM node:alpine as base
RUN apk --no-cache add pkgconfig autoconf automake libtool nasm build-base zlib-dev
# Set the working directory to /app
WORKDIR /app
# Copy package.json and yarn.lock files to the container
COPY package.json yarn.lock ./
# Install dependencies
RUN yarn install --production && \
yarn cache clean
# Use a separate build stage to compile the application
FROM base as build
# Copy the rest of the application files to the container
COPY . .
# Build the application
RUN npm run build && \
npm prune --production
# Use a minimal base image for the final image
FROM node:alpine
# Set the working directory to /app
WORKDIR /app
# Copy the application files from the build stage to the final image
COPY --from=build /app .
# Expose port 8089 for the application
EXPOSE 8089
# Start the application when the container starts
CMD ["npm", "run", "serve"]
serve: clean
@node generate.js lessons docs beta
@node generate.js wasm docs/webassembly beta
@cd docs && python3 -m http.server 8080
test: clean
@node generate.js lessons docs
@node generate.js wasm docs/webassembly
@cd docs && python3 -m http.server 8080
publish: clean
git branch -D gh-pages
git checkout -b gh-pages
@node generate.js lessons docs
@node generate.js wasm docs/webassembly
mv docs/* .
git add . || true
git commit -m 'generating new html' || true
git push -f origin gh-pages || true
git checkout master
lint:
#prettier --write lessons/*/*.yaml
#prettier --write wasm/*/*.yaml
clean:
@rm docs/*.html 2> /dev/null || true
@rm docs/webassembly/*.html 2> /dev/null || true
# Rust Tutorial Frontend
자기주도프로젝트 최석원
\ No newline at end of file
const showdown = require("showdown");
const fs = require("fs");
const yaml = require("js-yaml");
const lessonSource = process.argv[2];
const targetDir = process.argv[3];
/**
* @param {number} num
* @returns {string}
*/
function pad(num) {
const s = `${num}`;
return s.padStart(2, "0");
}
/**
* @param {string} lang
* @param {number} i
* @param {boolean} isBeta currently unused
* @param {string} chapter
* @returns {string}
*/
function getFileName(lang, i, isBeta, chapter) {
if (i === 0 && lang === "ko") {
return "index.html";
}
// let fileName = `${pad(i)}_${lang}.html`;
let fileName = `${pad(i)}_${lang}.html`;
if (chapter !== undefined && chapter !== null) {
fileName = `chapter_${chapter}_${lang}.html`;
}
return fileName;
}
/**
* @param {string} source
* @returns {string[]}
*/
const getDirectories = source =>
fs
.readdirSync(source, { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => dirent.name);
/**
* @param {string} path
* @returns {any}
*/
const getYaml = path => yaml.load(fs.readFileSync(path));
const languages = getDirectories(lessonSource);
const commonWords = {};
const chapters = [];
languages.forEach(lang => {
// const lang = languages[x];
const langDir = `${lessonSource}/${lang}`;
commonWords[lang] = getYaml(`${langDir}/common_words.yaml`);
const languageFiles = fs
.readdirSync(langDir, { withFileTypes: true })
.filter(f => f.isFile() && f.name.indexOf("chapter_") === 0)
.map(f => f.name);
languageFiles.forEach(l => {
const chap = parseInt(l.substring(8, l.indexOf(".")), 10);
if (chapters[chap] === undefined) {
chapters[chap] = {};
}
chapters[chap][lang] = getYaml(`${langDir}/${l}`);
});
});
const pages = [];
chapters.forEach((c, x) => {
for (let i = 0; i < c.ko.length; i += 1) {
const page = {};
if (i === 0 && x !== 0) {
page.chapter = x;
}
Object.keys(c).forEach(lang => {
page[lang] = c[lang][i];
});
pages.push(page);
}
});
const lessons = {
common_words: commonWords,
pages,
};
const converter = new showdown.Converter();
/**
* @param {string[]} words
* @param {string} lang
* @param {string} w
* @returns {string}
*/
function getWord(words, lang, w) {
if (words[lang][w]) {
return words[lang][w];
}
return words.ko[w];
}
/**
*
* @param {string[]} words
* @param {string} lang
* @returns {string}
*/
const getHead = (words, lang) => `<!DOCTYPE html>
<html lang="${lang}">
<head>
<title>Rust 튜토리얼 - 자기주도프로젝트</title>
<meta charset="UTF-8">
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="keywords" content="Rust, Programming, Learning">
<meta name="description" content="Rust tutorial website based on tour_of_rust">
<meta name="theme-color" content="#ff6801"/>
<meta http-equiv="Cache-Control" content="max-age=3600">
<link rel="stylesheet" href="tour.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/night-owl.min.css">
<script src="//unpkg.com/@highlightjs/cdn-assets@11.7.0/highlight.min.js"></script>
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="./site.webmanifest">
<script src="./tour.js" defer></script>
<script>hljs.highlightAll();</script>
</head>`;
/**
* @param {Array} lessons
* @param {string} lang
* @param {string} title
* @param {string} code
* @param {string} content
* @param {number} index
* @param {boolean} isLast
* @param {string[]} words
* @param {boolean} isBeta
* @returns
*/
function template(
lessonsData,
lang,
title,
code,
content,
index,
isLast,
words,
isBeta
) {
return `${getHead(words, lang)}
<body>
<div class="tour">
<div class="header">
<span class="title"><a href="${getFileName(
lang,
0,
isBeta,
lessonsData[0]?.chapter
)}">${getWord(words, lang, "tor")}</a></span>
<span class="nav">
<span class="toc"><a href="TOC_${lang}.html">${getWord(
words,
lang,
"toc"
)}</a></span>
</div>
<div class="page">
<h1>${title}</h1>
${content}
<div class="bottomnav">
${
index !== 0
? `<span class="back"><a href="${
isBeta ? "beta_" : ""
}${getFileName(
lang,
index - 1,
isBeta,
lessonsData[index - 1]?.chapter
)}" rel="prev">❮ ${getWord(
words,
lang,
"previous"
)}</a></span>`
: ""
}
${
isLast
? ""
: `<span class="next"><a href="${
isBeta ? "beta_" : ""
}${getFileName(
lang,
index + 1,
isBeta,
lessonsData[index + 1]?.chapter
)}" rel="next">${getWord(
words,
lang,
"next"
)} ❯</a></span>`
}
</div>
</div>
${
code
? `<div class="code">
<iframe id="rust-playground" width="100%" src="${code}" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals" title="Rust Playground" loading="lazy"></iframe>
</div>`
: '<div class="code"><center><img src="/ferris_lofi.png" alt="Mascot Ferris" width="300" height="236"></center></div>'
}
</div>
<!-- <script>
document.addEventListener("DOMContentLoaded", function() {
// Select the widget's text element using its XPath
const xpath = '/html/body/main/div/div/div[1]/div[1]/div/button[1]/div';
const widgetText = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
// Change the text content of the element
widgetText.textContent = "New Text";
});
</script> -->
</body>
</html>`;
}
languages.forEach(lang => {
let c = 0;
const words = lessons.common_words;
const langLessons = lessons.pages.filter(x => {
return true;
});
const betaLessons = lessons.pages.filter(() => true);
langLessons.forEach((lesson, i) => {
let fileName = getFileName(lang, i, false, lesson?.chapter);
if (i === 0 && lang === "ko") {
fileName = "index.html";
}
let lessonTitle = `[${getWord(words, lang, "untranslated")}] ${
lesson.ko.title
}`;
let lessonContent = converter.makeHtml(lesson.ko.content_markdown);
let lessonCode = lesson.ko.code;
if (lesson[lang]) {
let targetLang = lang;
if (lesson[lang].clone) {
targetLang = lesson[lang].clone;
}
lessonTitle = lesson[targetLang].title;
let content = lesson[targetLang].content_html;
if (!content) {
content = converter.makeHtml(lesson[targetLang].content_markdown);
}
lessonContent = content;
lessonCode = lesson[targetLang].code || lesson.ko.code;
if (lesson[lang].clone) {
if (lesson[lang].code) {
lessonCode = lesson[lang].code;
}
}
}
fs.writeFileSync(
`${targetDir}/${fileName}`,
template(
langLessons,
lang,
lessonTitle,
lessonCode,
lessonContent,
c,
i === langLessons.length - 1,
words,
false
)
);
c += 1;
});
const fileName = `TOC_${lang}.html`;
fs.writeFileSync(
`${targetDir}/${fileName}`,
`${getHead(words, lang)}
<body>
<div class="tour">
<div class="header">
<span class="title"><a href="${getFileName(lang, 0)}">${getWord(
words,
lang,
"tor"
)}</a></span>
<span class="nav">
</span>
</div>
<div>
<h1>${getWord(words, lang, "lessons")}</h1>
<ul>
${langLessons
.map((x, i) => {
let targetLang = lang;
if (x[lang] && x[lang].clone) {
targetLang = x[lang].clone;
}
let s = `<li><a href="${getFileName(lang, i, false, x.chapter)}">${
x[targetLang]
? x[targetLang].title
: `[${getWord(words, targetLang, "untranslated")}] ${
x.ko.title
}`
}</a></li>`;
if (x.chapter !== undefined) {
s = `</ul><h3><a href="${getFileName(
lang,
i,
false,
x.chapter
)}">${
x[targetLang]
? x[targetLang].title
: `[${getWord(words, targetLang, "untranslated")}] ${
x.ko.title
}`
}</a></h3><ul>`;
}
return s;
})
.join("\n")}
</ul>
</div>
</div>
</body>
</html>`
);
});
## 챕터
| Chapter | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| ------- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
- title: >-
Hello World!
code: >-
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&code=%2F%2F%20C-family%20%EC%96%B8%EC%96%B4%2C%20%EB%A9%94%EC%9D%B8%20%ED%95%A8%EC%88%98%EC%97%90%EC%84%9C%20%EC%8B%9C%EC%9E%91%ED%95%A8%0Afn%20main()%20%7B%0A%20%20%20%20println!(%22Hello%20%EB%9F%AC%EC%8A%A4%ED%8A%B8%F0%9F%A6%80%22)%3B%20%2F%2F%20%EC%A3%BC%EC%84%9D%0A%7D%0A
content_markdown: |
<img src="/intro.webp" alt="Welcome to Rust" style="width: 100%; margin-bottom: 20px; border-radius: 10px;">
Mirror 1: [http://rust-study.ajousw.kr/](http://rust-study.ajousw.kr/index.html)
Mirror 2: [https://hi-rust.github.io/](https://hi-rust.github.io/index.html)
Binary: [Windows](https://github.com/Alfex4936/Rust-Tutorial/releases/download/v1.0.0/Rust.Tutorial_1.0.0_x64_Windows.msi) | [Mac](https://) | [Linux](https://) - TODO
**자기주도프로젝트 🎉**
안녕하세요. 자기주도프로젝트 Rust 튜토리얼 영상을 위한 웹사이트입니다.
`프로그래밍 기초 지식이 있는 분들을 타겟`으로 만들었습니다. (C & Python)
키보드 <span class="emoji">⬅️</span>/<span class="emoji">➡️</span> 버튼으로 페이지를 이동할 수 있습니다.
질문이 있다면 <code>ikr@kakao.com</code> 로 메일 남겨주세요.
- Rust 언어 소개
- Rust 언어 기본 문법
- Rust 언어 고급 (비동기, Unsafe, 매크로 등)
- Rust 언어 간단한 유저 라이브러리 제작 및 업로드
- Rust 언어로 Python 언어 라이브러리 제작
- Rust 언어 웹 프레임워크를 이용한 카카오톡 챗봇 서버 제작
- title: >-
Rust 언어 소개
code: >-
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&code=fn+main%28%29+%7B%0A++++%2F%2F+%EC%83%81%ED%99%A9%3A+%EC%86%8C%EC%9C%A0%EA%B6%8C+%EC%9D%B4%EC%A0%84%ED%95%98%EA%B8%B0%0A++++let+mut+x+%3D+String%3A%3Afrom%28%22hello%22%29%3B%0A++++let+y+%3D+x%3B+%2F%2F+x%EC%9D%98+%EC%86%8C%EC%9C%A0%EA%B6%8C%EC%9D%B4+y%EB%A1%9C+%EC%9D%B4%EC%A0%84%EB%90%A8%0A++++println%21%28%22%7B%7D%22%2C+y%29%3B+%2F%2F+%EA%B2%B0%EA%B3%BC%3A+hello%0A+++++++++++++++++++++++%2F%2F+println%21%28%22%7B%7D%22%2C+x%29%3B+%2F%2F+%EC%98%A4%EB%A5%98%3A+%60x%60%EC%9D%98+%EC%86%8C%EC%9C%A0%EA%B6%8C%EC%9D%B4+y%EB%A1%9C+%EC%9D%B4%EC%A0%84%EB%90%98%EC%96%B4+%EB%8D%94+%EC%9D%B4%EC%83%81+%EC%82%AC%EC%9A%A9%ED%95%A0+%EC%88%98+%EC%97%86%EC%9D%8C%0A%0A++++%2F%2F+%EC%83%81%ED%99%A9%3A+%EB%8C%80%EC%97%AC%ED%95%98%EA%B8%B0%0A++++let+v+%3D+vec%21%5B1%2C+2%2C+3%5D%3B%0A++++let+s+%3D+sum%28%26v%29%3B+%2F%2F+v%EB%A5%BC+%EB%B6%88%EB%B3%80%EC%9C%BC%EB%A1%9C+%EB%8C%80%EC%97%AC%ED%95%98%EA%B3%A0+%ED%95%A9%EA%B3%84%EB%A5%BC+%EA%B5%AC%ED%95%9C%EB%8B%A4.%0A++++println%21%28%22%7B%7D%22%2C+s%29%3B+%2F%2F+%EA%B2%B0%EA%B3%BC%3A+6%0A%0A++++let+k+%3D+v%3B%0A++++%2F%2F+println%21%28%22%7B%3A%23%3F%7D%22%2C+v%29%3B+%2F%2F+error%5BE0382%5D%3A+borrow+of+moved+value%3A+%60v%60%0A%7D%0A%0Afn+sum%28v%3A+%26Vec%3Ci32%3E%29+-%3E+i32+%7B%0A++++let+mut+result+%3D+0%3B%0A++++for+i+in+v+%7B%0A++++++++result+%2B%3D+*i%3B%0A++++%7D%0A++++result%0A%7D%0A
content_markdown: |
<div align="center">
<p>
<img src="https://user-images.githubusercontent.com/2356749/223437049-ef50db6b-1ba4-4087-b67f-efeca5569201.png" alt="Rust logo" style="width: 20%; margin-bottom: 20px; border-radius: 10px;">
</p>
<h3>Rust official logo</h3>
</div>
> I burnt out; ran out of emotional energy to be effective in my role as technical lead for the project mid way through 2013 (at the tail end of my divorce, and while recovering from a surgery -- not a great time in my life), so I took a break, switched off the Rust team - Graydon Hoare
Rust는 Firefox 브라우저로 유명한 Mozilla의 개발자 [Graydon Hoare에 의해 2006년](https://arxiv.org/pdf/2206.05503&ved=2ahUKEwjT9o-23NX9AhVw5XMBHYQQB74QFnoECBwQAQ&usg=AOvVaw1uVD6znXuafpUqPN3jkm9C)에 첫 시작된 <s>지금은 Swift 언어 기여자</s>
안전하고 빠른 시스템 개발을 위한 언어로, 다음과 같은 이유에서 다양한 분야에서 점점 더 많이 사용:
<div align="center">
<p>
<img src="https://user-images.githubusercontent.com/2356749/224587883-afa83e65-f531-46d4-9580-c341052a0981.png">
</p>
<h3>소유권 및 빌리기 예제</h3>
</div>
- <b>안전성</b>: 메모리 안정성과 스레드 안전성을 강조하는 언어, Rust 컴파일러는 실행 시간 오류를 줄이기 위해 메모리 오류를 검출하고, 이를 방지하기 위해 안전한 코드를 작성할 수 있도록 도움
- <b>높은 성능</b>: 꽤 많은 경우에서 C와 비슷한 수준의 성능을 낼 수도 있음, LLVM을 사용하여 코드를 컴파일하고 최적화하여 빠른 실행 속도를 제공
- <b>확장성</b>: 다양한 운영 체제와 아키텍처를 지원, 크로스 플랫폼 개발에 적합하며, 다양한 분야에서 사용
- <b>생산성</b>: 코드의 가독성을 강조하며, 표준 라이브러리와 함께 제공되는 Cargo를 통해 의존성 관리와 빌드 자동화를 지원
- <b>지속 가능성</b>: 대형 기업들이 개발하고 사용하고 있으며, 다양한 커뮤니티와 생태계가 활발하게 운영
<div align="center">
<p>
<img src="https://user-images.githubusercontent.com/2356749/224588206-b98317ef-be24-450e-b825-cc98bf7984bb.png">
</p>
<h3>CPU time 벤치마크</h3>
</div>
- title: >-
Rust 언어 소개 cont'd
code: >-
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&code=%23!%5Ballow(dead_code)%5D%0A%0A%2F%2F%20%EC%84%9C%EB%A1%9C%20%EB%8B%A4%EB%A5%B8%20%EB%9D%BC%EC%9D%B4%ED%94%84%ED%83%80%EC%9E%84%EC%9D%84%20%EA%B0%80%EC%A7%84%20%EB%91%90%20%EA%B0%9C%EC%9D%98%20%EC%B0%B8%EC%A1%B0%EB%A5%BC%20%ED%8F%AC%ED%95%A8%ED%95%98%EB%8A%94%20%EA%B5%AC%EC%A1%B0%EC%B2%B4%0Astruct%20Foo%3C'a%2C%20'b%3E%20%7B%0A%20%20%20%20x%3A%20%26'a%20i32%2C%0A%20%20%20%20y%3A%20%26'b%20i32%2C%0A%7D%0A%0A%2F%2F%20Foo%20%EA%B5%AC%EC%A1%B0%EC%B2%B4%EB%A5%BC%20%EA%B0%80%EC%A0%B8%EC%99%80%EC%84%9C%20x%EC%99%80%20%EB%8F%99%EC%9D%BC%ED%95%9C%20%EB%9D%BC%EC%9D%B4%ED%94%84%20%ED%83%80%EC%9E%84%EC%9D%84%20%EA%B0%80%EC%A7%84%20%EC%B0%B8%EC%A1%B0%EB%A5%BC%20%EB%B0%98%ED%99%98%ED%95%98%EB%8A%94%20%ED%95%A8%EC%88%98%0Afn%20get_x%3C'a%2C%20'b%3E(foo%3A%20%26Foo%3C'a%2C%20'b%3E)%20-%3E%20%26'a%20i32%20%7B%0A%20%20%20%20foo.x%0A%7D%0A%0A%2F%2F%20%EC%9B%90%EC%8B%9C%20%ED%8F%AC%EC%9D%B8%ED%84%B0%EB%A5%BC%20%EA%B0%80%EC%A0%B8%EC%99%80%20%EC%9E%84%EC%9D%98%EC%9D%98%20%EB%9D%BC%EC%9D%B4%ED%94%84%ED%83%80%EC%9E%84%EC%9D%84%20%EA%B0%80%EC%A7%84%20%EC%B0%B8%EC%A1%B0%EB%A5%BC%20%EB%B0%98%ED%99%98%ED%95%98%EB%8A%94%20unsafe%20%ED%95%A8%EC%88%98%0Aunsafe%20fn%20deref_raw%3C'a%3E(ptr%3A%20*const%20i32)%20-%3E%20%26'a%20i32%20%7B%0A%20%20%20%20%26*ptr%20%2F%2F%20dereference%20raw%20pointer%0A%7D%0A%0Afn%20main()%20%7B%0A%20%20%20%20let%20x%20%3D%2010%3B%0A%20%20%20%20let%20y%20%3D%2020%3B%0A%0A%20%20%20%20%2F%2F%20x%EC%99%80%20y%EC%97%90%20%EB%8C%80%ED%95%9C%20%EC%B0%B8%EC%A1%B0%EB%A5%BC%20%ED%8F%AC%ED%95%A8%ED%95%98%EB%8A%94%20Foo%20%EA%B5%AC%EC%A1%B0%EC%B2%B4%20%EB%A7%8C%EB%93%A4%EA%B8%B0%0A%20%20%20%20let%20foo%20%3D%20Foo%20%7B%20x%3A%20%26x%2C%20y%3A%20%26y%20%7D%3B%0A%0A%20%20%20%20%2F%2F%20get_x%20%ED%98%B8%EC%B6%9C%ED%95%98%EB%A9%B4%EC%84%9C%20foo.x%EC%99%80%20%EB%8F%99%EC%9D%BC%ED%95%9C%20%EB%9D%BC%EC%9D%B4%ED%94%84%ED%83%80%EC%9E%84%EC%9D%84%20%EA%B0%80%EC%A7%84%20x%EC%97%90%20%EB%8C%80%ED%95%9C%20%EC%B0%B8%EC%A1%B0%20%EA%B0%80%EC%A0%B8%EC%98%A4%EA%B8%B0%0A%20%20%20%20let%20r1%20%3D%20get_x(%26foo)%3B%0A%0A%20%20%20%20%2F%2F%20r1%EC%97%90%EC%84%9C%20%EC%9B%90%EC%8B%9C(raw)%20%ED%8F%AC%EC%9D%B8%ED%84%B0%20%EB%A7%8C%EB%93%A4%EA%B8%B0%0A%20%20%20%20let%20ptr%20%3D%20r1%20as%20*const%20i32%3B%0A%0A%20%20%20%20%2F%2F%20deref_raw%20%ED%98%B8%EC%B6%9C%ED%95%B4%EC%84%9C%20%EC%9E%84%EC%9D%98%EC%9D%98%20%EB%9D%BC%EC%9D%B4%ED%94%84%ED%83%80%EC%9E%84%20'a%EB%A5%BC%20%EA%B0%80%EC%A7%84%20r1%EC%97%90%20%EB%8C%80%ED%95%9C%20%EC%B0%B8%EC%A1%B0%20%EA%B0%80%EC%A0%B8%EC%98%A4%EA%B8%B0%0A%20%20%20%20let%20r2%20%3D%20unsafe%20%7B%20deref_raw(ptr)%20%7D%3B%0A%0A%20%20%20%20%2F%2F%20r1%EA%B3%BC%20r2%EC%9D%98%20%EA%B0%92%EC%9D%84%20%EC%B6%9C%EB%A0%A5%ED%95%98%EA%B8%B0%0A%20%20%20%20println!(%22r1%20%3D%20%7B%7D%2C%20r2%20%3D%20%7B%7D%22%2C%20r1%2C%20r2)%3B%20%20%2F%2F%20r1%20%3D%2010%2C%20r2%20%3D%2010%0A%7D%0A
content_markdown: |
<div align="center">
<p>
<img src="https://user-images.githubusercontent.com/2356749/223428889-67c3ad26-41e4-4469-b008-ec2c0b493e42.png">
</p>
<h3>Stackoverflow survey @ 2022</h3>
</div>
2022년 Stack Overflow 개발자 설문조사 기준으로 Rust는 "가장 사랑받는 언어" 부문에서 `7년 연속`으로 1위를 차지할 정도입니다.
실제 예로 IT 대기업들 Facebook, Google, Mozilla 등이 Rust를 사용하고 있습니다.
- `Facebook`은 Rust를 기반으로 하는 Libra, 디지털 자산을 위한 글로벌 금융 시스템을 구축하는 것을 목표 블록체인 프로젝트를 진행, HHVM, API etc
- `Google`은 안드로이드 운영 체제의 새로운 버전에 Rust를 도입, crosvm, Fuchsia OS, etc
- `Discord`, Discord의 크로스 플랫폼 클라이언트 애플리케이션인 Discord Desktop은 Rust로 작성된 인터페이스 레이어로 구성, Discord Desktop의 인터페이스 레이어는 Chromium Embedded Framework (CEF)을 사용하며, Rust 코드는 CEF의 C++ 래퍼에서 호출됨. 또한 대규모 분산 시스템 처리에 쓰임
- `Mozilla`는 Firefox 브라우저의 일부를 Rust로 작성하여 메모리 안정성을 강화했으며, Rust를 사용하여 Servo라는 웹 렌더링 엔진을 개발, 또한 Rust로 작성된 Cranelift 프로젝트를 통해 LLVM 대체를 위한 컴파일러 및 라이브러리를 제공, 또한 Mozilla의 모바일 운영 체제인 Firefox OS에서 Rust를 사용하는 것도 고려
- `Linux`, C언어만 좋아하는 linus torvald가 linux kernel 6.1부터 공식 지원 언어로 추가
- `Amazon`, Bottlerocket 운영 체제와 AWS 니트로 시스템, etc
- `Dropbox`, 클라우드 스토리지 회사인 드롭박스는 Rust를 사용하여 안전하고 효율적인 파일 검색 및 동기화 엔진을 구축 (exa byte storage)
<div align="center">
<p>
<img src="https://user-images.githubusercontent.com/2356749/223660836-5a3dd239-4ddb-432b-9a4a-2e6ac90816ee.png">
</p>
</div>
이제 Rust 팬처럼만 이야기 하지 말고 Rust 언어가 전체적으로 어떻게 작동하는지 자세히 알아보겠습니다.
---
`Rust`는 메모리 안정성, 스레드 안전성, 코드 가독성 등을 강조하는 언어입니다.
`가비지 컬렉션이나 런타임 오버헤드 없이` 메모리를 안전하게 보호할 수 있어 최신 컴퓨팅에서 매우 유용합니다.
이러한 기능 덕분에 Rust는 빠르고 안정적이며 효율적인 소프트웨어를 작성하는 데 완벽한 언어입니다.
객체 지향 프로그래밍을 지원하지만, 이를 구현하는 방식이 다릅니다.
"트레잇(trait)"이라는 개념을 사용하여 `객체 지향 프로그래밍`을 구현하고 `연산자 오버로딩을 지원`하며, 이를 통해 객체 지향적인 코드를 작성할 수 있습니다.
`암묵적인 타입 변환`을 지원하지 않습니다. Rust에서는 `C와 직접적으로 상호작용`할 수 있는 Foreign Function Interface(FFI)가 제공됩니다.
Rust는 LLVM(컴파일러 인프라스트럭처) 프로젝트의 일부로 개발되어 `LLVM`을 사용하여 코드를 컴파일하고 최적화하여 빠른 실행 속도를 제공합니다.
Rust는 또한 npm처럼 `패키지 매니저 Cargo`를 내장해 의존성 관리와 빌드 자동화를 지원합니다.
<div align="center">
<p>
<img src="https://doc.rust-lang.org/cargo/images/Cargo-Logo-Small.png">
</p>
</div>
- title: >-
Rust 언어 설치
code: >-
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&code=curl%20--proto%20'%3Dhttps'%20--tlsv1.2%20-sSf%20https%3A%2F%2Fsh.rustup.rs%20%7C%20sh
content_markdown: |
[https://rustup.rs/](https://rustup.rs/)
[`Microsoft C++ Build Tools`](https://visualstudio.microsoft.com/ko/visual-cpp-build-tools/)
[@Link](https://www.rust-lang.org/tools/install)
<div align="center">
<p>
<img src="https://user-images.githubusercontent.com/2356749/223654372-637cbfd5-06f3-4c20-b97c-aefcdbbdafe6.png">
</p>
</div>
<div align="center">
<p>
<img src="https://user-images.githubusercontent.com/2356749/223654483-ba1db2fa-cc6b-4104-93ca-456852d2b4e5.png">
</p>
</div>
- title: >-
Chapter 0 - 마무리
content_markdown: |
Rust 소스코드는 `.rs` 확장자를 가집니다.
```rust
fn main() {
println!("Hello, world!");
}
```
위 코드는 가장 간단한 Rust 프로그램입니다.
main 함수를 정의하고, println! 매크로를 사용하여 "Hello, world!"를 출력하도록 되어 있습니다.
위 코드를 hello.rs라는 이름으로 저장한 뒤, 터미널에서 다음과 같은 명령어를 입력해보세요.
```bash
$ rustc hello.rs
$ ./hello
$ Hello, world! (stdout)
```
`Google evcxr` - [Rust REPL](https://github.com/evcxr/evcxr)
- title: Chapter 1 - The Basics
content_markdown: >
무슨 언어를 배우든 똑같이 기본부터 살펴보겠습니다. (변수, 함수, 클래스 등)
Rust 언어 비공식이지만 거의 흔하게 쓰이는 마스코트, 게(crab)의 이름은 **Ferris** 입니다.
<pre><code>let ferris = crab!()</code></pre>
또한 Rust를 사용하거나, 기여하거나 관심이 있는 사람들을 **Rustacean**[러스테이션] 라고 부릅니다.
- title: The Rust Playground
code: >-
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=fn%20main()%20%7B%0A%20%20%20%20println!(%22Welcome%20to%20the%20playground!%20You%20can%20modify%20the%20code%20in%20here.%22)%3B%0A%7D%0A
content_markdown: >
이 웹사이트에서는 [Rust
Playground](https://play.rust-lang.org) 를 사용하여 온라인에서 직접 실행해 볼 수 있습니다.
우측에서 보다시피 <code>println()</code>도 아닌 <code>println!()</code> 와 같은 코드를 사용하여 stdout에 출력하는 것을 볼 수 있습니다.
`!` 이것은 매크로 (Macro)라는 Rust 언어의 특별한 기능 중 하나인데 우선은 생김새만 알고 나중에 뭔지 알아보겠습니다.
Rust 언어는 쉽게 작성할 수 있도록 (syntactic sugar) 도와주지만 사실은 컴파일러가 아래처럼 처리합니다.
(`cargo inspect` 명령어)
<pre><code class="rust">#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2018::*;
#[macro_use]
extern crate std;
fn main() {
{
::std::io::_print(format_args!("Welcome to the playground! You can modify the code in here.\n"));
};
}
</code></pre>
- title: 변수
code: >-
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&code=fn%20main()%20%7B%0A%20%20%20%20%2F%2F%20let%20%ED%82%A4%EC%9B%8C%EB%93%9C%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20%EB%B3%80%EC%88%98%EB%A5%BC%20%EC%84%A0%EC%96%B8%ED%95%A9%EB%8B%88%EB%8B%A4.%0A%20%20%20%20let%20x%20%3D%205%3B%20%2F%2F%20x%EC%97%90%205%EB%9D%BC%EB%8A%94%20%EA%B0%92%EC%9D%84%20%ED%95%A0%EB%8B%B9%ED%95%A9%EB%8B%88%EB%8B%A4.%0A%20%20%20%20let%20y%3A%20f32%20%3D%203.14%3B%20%2F%2F%20y%EC%97%90%203.14%EB%9D%BC%EB%8A%94%20%EA%B0%92%EC%9D%84%20%ED%95%A0%EB%8B%B9%ED%95%98%EB%A9%B0%2C%20f32%20%ED%83%80%EC%9E%85%EC%9D%84%20%EB%AA%85%EC%8B%9C%EC%A0%81%EC%9C%BC%EB%A1%9C%20%EC%A7%80%EC%A0%95%ED%95%A9%EB%8B%88%EB%8B%A4.%0A%0A%20%20%20%20%2F%2F%20Rust%EB%8A%94%20%EB%8C%80%EB%B6%80%EB%B6%84%EC%9D%98%20%EA%B2%BD%EC%9A%B0%20%EB%B3%80%EC%88%98%EC%9D%98%20%ED%83%80%EC%9E%85%EC%9D%84%20%EC%B6%94%EB%A1%A0%ED%95%A0%20%EC%88%98%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4.%0A%20%20%20%20%2F%2F%20%EB%A7%8C%EC%95%BD%20%ED%83%80%EC%9E%85%EC%9D%84%20%EB%AA%85%EC%8B%9C%EC%A0%81%EC%9C%BC%EB%A1%9C%20%EC%A7%80%EC%A0%95%ED%95%98%EA%B3%A0%20%EC%8B%B6%EB%8B%A4%EB%A9%B4%20%EB%8B%A4%EC%9D%8C%EA%B3%BC%20%EA%B0%99%EC%9D%B4%20%EC%9E%91%EC%84%B1%ED%95%A9%EB%8B%88%EB%8B%A4.%0A%20%20%20%20let%20z%3A%20i64%20%3D%20100%3B%0A%0A%20%20%20%20%2F%2F%20%EB%B3%80%EC%88%98%EC%9D%98%20%EC%9D%B4%EB%A6%84%EC%9D%84%20%EC%97%AC%EB%9F%AC%20%EB%B2%88%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20%EA%B0%92%EC%9D%84%20%ED%95%A0%EB%8B%B9%ED%95%A0%20%EC%88%98%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4.%0A%20%20%20%20let%20mut%20count%20%3D%200%3B%0A%20%20%20%20count%20%3D%201%3B%0A%20%20%20%20count%20%3D%202%3B%0A%0A%20%20%20%20%2F%2F%20%EB%B3%80%EC%88%98%EC%9D%98%20%ED%83%80%EC%9E%85%EC%9D%84%20%EB%B3%80%EA%B2%BD%ED%95%98%EC%97%AC%20%EC%9E%AC%EC%82%AC%EC%9A%A9%ED%95%A0%20%EC%88%98%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4.%0A%20%20%20%20let%20x%20%3D%20%22hello%22%3B%20%2F%2F%20x%EB%8A%94%20%EB%AC%B8%EC%9E%90%EC%97%B4%20%ED%83%80%EC%9E%85%EC%9E%85%EB%8B%88%EB%8B%A4.%0A%20%20%20%20let%20x%20%3D%205%3B%20%2F%2F%20x%EB%8A%94%20%EC%A0%95%EC%88%98%20%ED%83%80%EC%9E%85%EC%9C%BC%EB%A1%9C%20%EB%B3%80%EA%B2%BD%EB%90%A9%EB%8B%88%EB%8B%A4.%0A%0A%20%20%20%20%2F%2F%20%EB%B3%80%EC%88%98%EC%9D%98%20%EC%9D%B4%EB%A6%84%EC%9D%80%20snake_case%EB%A1%9C%20%EC%9E%91%EC%84%B1%ED%95%A9%EB%8B%88%EB%8B%A4.%0A%20%20%20%20let%20first_name%20%3D%20%22Choi%22%3B%0A%20%20%20%20let%20last_name%20%3D%20%22Blah%22%3B%0A%0A%20%20%20%20%2F%2F%20%EB%B3%80%EC%88%98%EC%9D%98%20%EA%B0%92%EC%9D%84%20%EC%B6%9C%EB%A0%A5%ED%95%A9%EB%8B%88%EB%8B%A4.%0A%20%20%20%20println!(%22x%20is%20%7B%7D%22%2C%20x)%3B%20%2F%2F%20%22x%20is%205%22%EA%B0%80%20%EC%B6%9C%EB%A0%A5%EB%90%A9%EB%8B%88%EB%8B%A4.%0A%7D%0A
content_markdown: >
Rust에서는 `let` 키워드를 사용하여 변수를 선언합니다.
<div align="center">
<p>
<img src="https://user-images.githubusercontent.com/2356749/223641752-4b38e61f-82f4-450d-b778-526cb7ad618c.png">
</p>
</div>
값을 할당할 때, Rust는 거의 대부분 변수의 타입을 추론할 수 있습니다.
만약 Rust가 추론하지 못하면 변수의 선언 시 타입을 추가할 수 있습니다.
변수의 이름을 여러 번 사용하여 값을 할당할 수 있습니다.
이를 "shadowing"이라고 하며, 변수의 타입은 재할당될 때마다 변경됩니다.
변수의 이름은 항상 `snake_case`로 작성합니다.
- title: 변수 업데이트
code: >-
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=fn%20main()%20%7B%0A%20%20%20%20let%20mut%20x%20%3D%2042%3B%0A%20%20%20%20println!(%22%7B%7D%22%2C%20x)%3B%0A%20%20%20%20x%20%3D%2013%3B%0A%20%20%20%20println!(%22%7B%7D%22%2C%20x)%3B%0A%7D%0A
content_markdown: >
Rust는 변수가 변경 가능한지 여부에 대해 많은 주의를 기울입니다.
* **mutable (가변)** - 컴파일러는 해당 변수에 대해 `쓰거나 읽을 수` 있도록 허용합니다.
* **immutable (불변)** - 컴파일러는 해당 변수에 대해서 `읽기만` 가능하도록 허용합니다.
가변 값은 **mut** 키워드로 구분됩니다.
- title: 기본 타입
code: >-
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=fn%20main()%20%7B%0A%20%20%20%20let%20x%20%3D%2012%3B%20%2F%2F%20by%20default%20this%20is%20i32%0A%20%20%20%20let%20a%20%3D%2012u8%3B%0A%20%20%20%20let%20b%20%3D%204.3%3B%20%2F%2F%20by%20default%20this%20is%20f64%0A%20%20%20%20let%20c%20%3D%204.3f32%3B%0A%20%20%20%20let%20bv%20%3D%20true%3B%0A%20%20%20%20let%20t%20%3D%20(13%2C%20false)%3B%0A%20%20%20%20let%20sentence%20%3D%20%22hello%20world!%22%3B%0A%20%20%20%20println!(%0A%20%20%20%20%20%20%20%20%22%7B%7D%20%7B%7D%20%7B%7D%20%7B%7D%20%7B%7D%20%7B%7D%20%7B%7D%20%7B%7D%22%2C%0A%20%20%20%20%20%20%20%20x%2C%20a%2C%20b%2C%20c%2C%20bv%2C%20t.0%2C%20t.1%2C%20sentence%0A%20%20%20%20)%3B%0A%7D%0A
content_markdown: >
Rust는 다양한 익숙한 유형을 제공합니다:
* booleans - `bool`로 참/거짓을 나타냅니다.
* unsigned integers (부호 없는 정수) - 음이 아닌 정수를 나타내는 `u8`, `u16`, `u32`, `u64`, `u128`입니다.
* signed integers (부호 있는 정수) - 정수를 나타내는 `i8`, `i16`, `i32`, `i64`, `i128`입니다.
* pointer sized integers - 메모리에서 색인과 항목의 크기를 나타내는 `usize`, `isize`입니다.
* floating point - `f32` `f64`
* tuple - 고정된 값의 시퀀스를 스택에 전달하는 `(value, value, ...)` 입니다.
* arrays - 컴파일 시점에서 크기가 고정되어 있는 비슷한 요소의 집합으로 `[value, value, ...]` 입니다.
* slices - 런타임에 길이가 알려진 비슷한 요소의 집합입니다.
* `str`(문자열 슬라이스) - 런타임에 길이가 알려진 텍스트입니다.
다른 언어에서 사용하는 것보다 텍스트는 더 복잡할 수 있습니다.
Rust가 시스템 프로그래밍 언어이기 때문에, 기존에 익숙하지 않은 메모리 문제에 대해서도 신경쓰고 있습니다.
이에 대해서는 나중에 자세히 다룰 예정입니다.
숫자형은 숫자 끝에 유형을 명시하여 명시적으로 지정할 수 있습니다(예: `13u32`, `2u8`).
- title: Basic Type Conversion
code: >-
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=fn%20main()%20%7B%0A%20%20%20%20let%20a%20%3D%2013u8%3B%0A%20%20%20%20let%20b%20%3D%207u32%3B%0A%20%20%20%20let%20c%20%3D%20a%20as%20u32%20%2B%20b%3B%0A%20%20%20%20println!(%22%7B%7D%22%2C%20c)%3B%0A%0A%20%20%20%20let%20t%20%3D%20true%3B%0A%20%20%20%20println!(%22%7B%7D%22%2C%20t%20as%20u8)%3B%0A%7D%0A
content_markdown: >
Rust는 숫자 변수 타입에 대해 알고 있어야하며, `u8`를 `u32`로 쉽게 사용할 수 없습니다.
다행히 Rust는 **as** 키워드를 사용하여 숫자형을 쉽게 변환할 수 있습니다.
- title: Constants
code: >-
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=const%20PI%3A%20f32%20%3D%203.14159%3B%0A%0Afn%20main()%20%7B%0A%20%20%20%20println!(%0A%20%20%20%20%20%20%20%20%22To%20make%20an%20apple%20%7B%7D%20from%20scratch%2C%20you%20must%20first%20create%20a%20universe.%22%2C%0A%20%20%20%20%20%20%20%20PI%0A%20%20%20%20)%3B%0A%7D%0A
content_markdown: >
상수는 변수와 달리 곳곳에서 사용되는 공통된 값을 효율적으로 지정하는 데 사용됩니다.
변수와 같은 곳에서 값이 복사되는 대신, 상수는 컴파일 시간에 사용되는 위치에서 직접 값을 대체합니다.
변수와 달리, 상수는 항상 명시적인 유형을 가져야 합니다.
상수 이름은 항상 `SCREAMING_SNAKE_CASE`로 지정됩니다.
- title: Arrays
code: >-
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=fn%20main()%20%7B%0A%20%20%20%20let%20nums%3A%20%5Bi32%3B%203%5D%20%3D%20%5B1%2C%202%2C%203%5D%3B%0A%20%20%20%20println!(%22%7B%3A%3F%7D%22%2C%20nums)%3B%0A%20%20%20%20println!(%22%7B%7D%22%2C%20nums%5B1%5D)%3B%0A%7D%0A
content_markdown: >
*배열*은 동일한 유형의 데이터 요소들의 **고정된 길이 집합**입니다.
*배열*의 데이터 유형은 `[T;N]` 입니다.
(T는 요소의 유형이고, N은 컴파일 시간에 알려진 고정 길이)
개별 요소는 `[x]` 연산자를 사용하여 가져올 수 있습니다.
여기서 x는 원하는 요소의 *usize* 인덱스(0부터 시작)입니다.
가변 길이의 컬렉션, 즉 가변 배열은 나중에 **Vectors**에 대한 챕터에서 소개됩니다.
- title: Functions
code: >-
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=fn%20add(x%3A%20i32%2C%20y%3A%20i32)%20-%3E%20i32%20%7B%0A%20%20%20%20return%20x%20%2B%20y%3B%0A%7D%0A%0Afn%20subtract(x%3A%20i32%2C%20y%3A%20i32)%20-%3E%20i32%20%7B%0A%20%20%20%20x%20-%20y%0A%7D%0A%0Afn%20main()%20%7B%0A%20%20%20%20println!(%2242%20%2B%2013%20%3D%20%7B%7D%22%2C%20add(42%2C%2013))%3B%0A%20%20%20%20println!(%2242%20-%2013%20%3D%20%7B%7D%22%2C%20subtract(42%2C%2013))%3B%0A%7D%0A
content_markdown: >
함수는 매개변수 (parameter)가 없거나 여러 개일 수 있습니다.
이 예제에서 *add* 함수는 `i32`(32비트 길이의 부호 있는 정수)형 두 개의 인수를 취합니다.
*subtract* 함수에서와 같이 표현식만 반환하려면 `return` 키워드와 세미콜론을 삭제할 수 있습니다.
함수 이름은 항상 `snake_case`로 지정됩니다.
힌트: 함수를 정의하는 경우, 해당 함수가 수신하는 데이터를 매개변수 (parameter)라고합니다.
그 함수를 호출하고 데이터를 전달하면 인수(argument)라고합니다.
- title: Multiple Return Values
code: >-
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=fn%20swap(x%3A%20i32%2C%20y%3A%20i32)%20-%3E%20(i32%2C%20i32)%20%7B%0A%20%20%20%20return%20(y%2C%20x)%3B%0A%7D%0A%0Afn%20main()%20%7B%0A%20%20%20%20%2F%2F%20return%20a%20tuple%20of%20return%20values%0A%20%20%20%20let%20result%20%3D%20swap(123%2C%20321)%3B%0A%20%20%20%20println!(%22%7B%7D%20%7B%7D%22%2C%20result.0%2C%20result.1)%3B%0A%0A%20%20%20%20%2F%2F%20destructure%20the%20tuple%20into%20two%20variables%20names%0A%20%20%20%20let%20(a%2C%20b)%20%3D%20swap(result.0%2C%20result.1)%3B%0A%20%20%20%20println!(%22%7B%7D%20%7B%7D%22%2C%20a%2C%20b)%3B%0A%7D%0A
content_markdown: >
함수는 값의 **튜플**을 반환하여 여러 값을 반환할 수 있습니다.
튜플 요소는 인덱스 번호를 사용하여 참조할 수 있습니다.
Rust는 여러 형식의 destructuring을 지원합니다.
우리는 더 많은 형태로 볼 것이며, 이를 통해 데이터 구조의 하위 요소를 직관적으로 추출할 수 있습니다.
- title: Returning Nothing
content_markdown: >
함수에 대해 반환 유형이 지정되어 있지 않으면, *unit*이라고도 하는 빈 튜플을 반환합니다.
빈 튜플은 `()`로 나타낼 수 있습니다.
`()`을 사용하는 것은 드문 경우이지만 충분히 자주 출현하기 때문에 무슨 일이 일어나는지 알아둘 가치가 있습니다.
code: >-
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=fn%20make_nothing()%20-%3E%20()%20%7B%0A%20%20%20%20return%20()%3B%0A%7D%0A%0A%2F%2F%20the%20return%20type%20is%20implied%20as%20()%0Afn%20make_nothing2()%20%7B%0A%20%20%20%20%2F%2F%20this%20function%20will%20return%20()%20if%20nothing%20is%20specified%20to%20return%0A%7D%0A%0Afn%20main()%20%7B%0A%20%20%20%20let%20a%20%3D%20make_nothing()%3B%0A%20%20%20%20let%20b%20%3D%20make_nothing2()%3B%0A%0A%20%20%20%20%2F%2F%20Printing%20a%20debug%20string%20for%20a%20and%20b%0A%20%20%20%20%2F%2F%20Because%20it's%20hard%20to%20print%20nothingness%0A%20%20%20%20println!(%22The%20value%20of%20a%3A%20%7B%3A%3F%7D%22%2C%20a)%3B%0A%20%20%20%20println!(%22The%20value%20of%20b%3A%20%7B%3A%3F%7D%22%2C%20b)%3B%0A%7D%0A
- title: Chapter 1 - 마무리
content_markdown: >
Rust의 기초는 그렇게 나쁘지 않죠?
시스템 프로그래밍 언어로서, Rust는 메모리 내 값을 매우 신경쓰며,
수정이 가능한지 불가능한지 여부, 그리고 수학 연산이 의도한 대로 수행되는지 확인합니다.
참고:
* [Youtube: Rust Cast - Rust의 기본 숫자 유형에 대한 더 깊은 이해](https://www.youtube.com/watch?v=n5TRBkbystY)
* [Website: Rust Book 2018 - 기본 데이터 유형에 대한 자세한 설명](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch03-02-data-types.html)
* [Website: Rust Cheat Sheet - Data Types](https://cheats.rs/#basic-types)
chapter: 챕터
tor: Rust 튜토리얼
next: 다음
previous: 이전
toc: 목차
lessons: 강의
untranslated: 번역 미정
welcometothe: Welcome to the
presstocontinue: Press to Continue
@echo off
if ["%~1"] == [""] (
goto :help
)
if "%~1" == "serve" (
goto :serve
)
if "%~1" == "test" (
goto :test
)
if "%~1" == "publish" (
goto :publish
)
if "%~1" == "lint" (
goto :lint
)
if "%~1" == "clean" (
goto :clean
)
:help
echo Usage:
echo make.bat [options]
echo.
echo Options:
echo serve Start the Python webserver
echo test Start the test Python webserver
echo publish Publish the website via Github pages
echo lint Run Prettier
echo clean Remove docs and wasm html pages
exit /b 0
:serve
call :clean
call node generate.js lessons docs
@REM beta
@REM call node generate.js wasm docs\webassembly beta
call cd docs && python -m http.server 8080
exit /b 0
:test
call :clean
call node generate.js lessons docs
call node generate.js wasm docs\webassembly
call cd docs && python -m http.server 8080
exit /b 0
:publish
call :clean
call git branch -D gh-pages
call git checkout -b gh-pages
call node generate.js lessons docs
call node generate.js wasm docs/webassembly
call mv docs\* .
call git add . || true
call git commit -m 'generating new html' || true
call git push -f origin gh-pages || true
call git checkout master
exit /b 0
:lint
call prettier --write .\lessons\*\*.yaml
call prettier --write .\wasm\*\*.yaml
exit /b 0
:clean
del .\docs\*.html
del .\docs\webassembly\*.html
exit /b 0
\ No newline at end of file
#!/bin/bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
export
cd /home/dev/Rust-Tutorial/rust_tutorial
export NODE_ENV=production
npm run serve
This diff is collapsed.
{
"name": "rust",
"private": true,
"version": "1.0.0",
"scripts": {
"lint:lessons": "prettier --write ./frontend/lessons/*/*.yaml",
"lint": "npm run lint:lessons && npm run lint:webassembly && eslint --fix generate.js docs/",
"prebuild": "npm run clean",
"build": "node ./frontend/generate.js ./frontend/lessons docs",
"serve": "npm run build && python fast.py",
"clean": "rimraf --glob ./docs/*.html",
"watch": "nodemon -w ./frontend/lessons/**/* -e yaml --exec npm run serve",
"tauri": "tauri"
},
"dependencies": {
"js-yaml": "^4.1.0",
"showdown": "^2.1.0"
},
"devDependencies": {
"@tauri-apps/cli": "^1.2.3",
"eslint": "^8.35.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.27.5",
"nodemon": "^2.0.21",
"prettier": "^2.8.4",
"rimraf": "^4.4.0"
}
}
\ No newline at end of file
rust-tutorial.site
\ No newline at end of file
public/images/hylee_512.jpg

50.3 KiB

body {
font-family: 나눔고딕;
margin: auto;
padding-left: 20px;
max-width: 1280px;
background-color: lightgray;
}
li {
font-size: 11pt;
margin: 4px;
}
table {
width: 95%;
border: 2px solid #777777;
font-size: 10pt;
}
th, td {
border: 1px solid grey;
padding-left: 3px;
padding-right: 3px;
}
# Generated by Cargo
# will have compiled files and executables
/target/
WixTools
# These are backup files generated by rustfmt
**/*.rs.bk
config.json
bundle.json
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment