Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

pannous/rust-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

321,091 Commits
x
x

Repository files navigation

Fork of official Rust

Rust is a conceptually beautiful language with sometimes horrible syntax.
We take the power of Rust and just make it more beautiful by removing avoidable bloat wherever we see it.

Philosophy:
β€’ 𓃀 π“„€ 𓏀 Beauty without compromising correctness

Features

working features

Convenience

β€’ shebang support: #!/usr/bin/env rust β€’ run rust as scripts with implicit main β€’ exit!() and exit() function β€’ put!(...) macro for generous printing β€’ Some(3) == 3 auto unwrap β€’ unused_mut warnings suppressed in script mode

Syntax Sugar

β€’ optional trailing semicolon;
β€’ optional comma between struct/class fields
β€’ # comments (Python/shell style)
β€’ := operator for let mut
β€’ var keyword for let mut
β€’ def add(a: int, b: int) int { a + b } # no -> needed
β€’ class keyword with auto-derives (Debug, Clone, Copy)
β€’ automatic derives for enums/structs/classes in script mode
β€’ go-style return type annotation (-> optional)
β€’ js-style arrow functions [1,2,3].apply(x=>x*2) == [2,4,6]
β€’ i++ and i-- increment/decrement

Boolean Operators

β€’ and, or, not, xor, Β¬, ∧, ∨ synonyms for archaic symbols && || !
β€’ truthy and falsy values in conditions if 1 { }
β€’ truthy optionals let z : i32? = None; if z { ... } else { put!("πŸ—Έ") }

Comparison & Range Operators

β€’ ≀ β‰₯ β‰  comparison operators
β€’ ... and ... inclusive range operators
β€’ in operator with auto-borrow: 2 in [1,2,3]

Math Features

β€’ ** power operator with int and float support
β€’ Approximate equality .1 + .2 β‰ˆ .3 (also ~ as synonym)
β€’ Julia-style implicit multiplication: 2Ο€ β†’ 2*Ο€
β€’ Ο„ (tau) and Ο€ (pi) constants baked in Ο„ == 2Ο€
β€’ int-float coercion and leading dot floats: .5 instead of 0.5

Strings

β€’ "strings" auto-convert to String (no more .to_string())
β€’ "year "+2026 string concatenation with + for various types
β€’ modulo strings and printf format specifiers "%d" % i
β€’ curly quote strings "hello" work globally
β€’ string case conversion: .upper() .lower() .capitalize()
β€’ 100+ convenience functions: "hello".reverse() = "olleh"

Optionals & Null Safety

β€’ Optionals via '?' as in other sane languages: i32? β€’ Optional chaining via ?. and ?? β€’ Unwrap shorthand via .! : val.! β†’ val.unwrap() β€’ nil as alias for None

Collections

β€’ Simple lists @[1, 2, 3] β†’ homogeneous Vec
β€’ Magic lists @["hello", 42, true] β†’ auto-wrapped Vec
β€’ {key: value} untyped map literal syntax
β€’ @{key: value} typed map literal syntax
β€’ for (key, value) in map.pairs()
β€’ for (index, value) in list.pairs()
β€’ [1,2,3].apply(x=>x*2) == [2,4,6]
β€’ [1, 2, 3, 4].chose(x => x%2 == 0) == [2,4]

Type Aliases & Casting

β€’ int = i32 float = f64 bool = boolean
β€’ as type conversion '1' as int == 1 , '1' as codepoint == 47 ...

Future features

β€’ functions return Results, yes, no need to write it
β€’ dynamic linking Swift ABI ...
β€’ dynamic linking with wit-like objects via dlsym C-ABI

See Goo the Go++ language extensions for a list of some planned features.

About

Fork of Rust as a beautiful scripting language

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

Contributors

Languages

  • Rust 90.2%
  • HTML 7.0%
  • Shell 0.7%
  • C 0.6%
  • JavaScript 0.5%
  • Python 0.3%
  • Other 0.7%

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /