NeuroWhAI의 잡블로그

[Rust] rusti 소개 - Interpret Rust 본문

개발 및 공부/언어

[Rust] rusti 소개 - Interpret Rust

NeuroWhAI 2018. 1. 5. 20:18



rusti는 파이썬과 같은 인터프리터 언어에선 당연히 되는, 하스켈의 GHCi 같은 기능을 제공하는 툴 입니다.

rusti=> 1 + 4
5
이런 느낌이죠.
Rust 식을 적으면 바로 실행해서 결과를 알려줍니다.

rusti=> use std::env;
rusti=> env::args().collect::<Vec<_>>()
["target/debug/rusti"]
rusti=> use std::iter::AdditiveIterator;
rusti=> (1..100).filter(|x| *x % 19 == 3).fold(0, |acc, x| acc + x)
303
당연히 이렇게 여러 명령어를 연계하는것도 됩니다.

명령어도 몇개 제공하는데 그중 .type 명령어는 식의 타입을 알려줍니다.
rusti=> .type Some("Hello world!".to_string())
Some("Hello world!".to_string()) = core::option::Option<collections::string::String>
rusti=> .type vec![1, 2, 3]
vec![1, 2, 3] = collections::vec::Vec<i32>
rusti=> .type std::io::stdin
std::io::stdin = fn() -> std::io::stdio::Stdin {std::io::stdio::stdin}

대체 무슨 원리인지 신기하네요;;
컴파일언어인데...?




Comments