-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/cargo/janus/rustix-0.37.25
- Loading branch information
Showing
20 changed files
with
1,131 additions
and
760 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/target/ | ||
/src/assets/*.lua |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Basic examples | ||
|
||
// This is a comment | ||
/* | ||
this also is. | ||
*/ | ||
|
||
// Declare variables | ||
let some_var = "foo"; | ||
let some_char = 'a'; // This is a number actually. | ||
some_char += 1; | ||
print(some_var, some_char); | ||
|
||
// Mutate them | ||
some_var = 5; | ||
some_var += 1; | ||
print(some_var); | ||
|
||
// Declare functions | ||
fn the_foo() { | ||
return "bar"; | ||
} | ||
|
||
// Use them | ||
let answer = the_foo(); | ||
print(answer); | ||
|
||
// Conditions | ||
if true { | ||
print("Of course"); | ||
} else { | ||
print("Never"); | ||
} | ||
|
||
// Do-block | ||
{ | ||
let this_is = "isolated from the rest"; | ||
print("of_the_code"); | ||
} | ||
|
||
// Can be used as an expression too! | ||
let my_var = "Foo"; | ||
let result = { | ||
let my_var = "another one"; | ||
return my_var ++ "."; | ||
}; | ||
print(result, my_var); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require("../src/assets/std"); | ||
|
||
let x = [1, 2, 3]; | ||
let y = [4, 5, 6]; | ||
let z = x ::: y; | ||
|
||
for (k, v) in entries(z) { | ||
print(k ++ " => " ++ v); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
// Example usage of extra operators: | ||
let { operator, entries } = require("../src/assets/std"); | ||
|
||
fn __pipe_right(left, right) { | ||
@operator("|>") | ||
fn pipe_right(left, right) { | ||
return right(left); | ||
} | ||
|
||
@operator("<|") | ||
fn pipe_left(left, right) { | ||
return left(right); | ||
} | ||
|
||
// Example usage of extra operators: | ||
let r = 101 | ||
|> (a => a + 10) | ||
|> (a => a * 2) | ||
|> tostring; | ||
|
||
print("Result = " ++ r ++ " (" ++ type(r) ++ ")"); | ||
let kind = type <| r |> a => "(" ++ a ++ ")"; | ||
|
||
print("Result = " ++ r ++ " " ++ kind); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
|
||
|
||
fn Test() { | ||
fn test() { | ||
return (target, name) => { | ||
print("Adding " ++ name ++ " to the test suite!"); | ||
}; | ||
} | ||
|
||
@Test() | ||
@test() | ||
fn my_func() { | ||
print("Some func"); | ||
} | ||
|
||
fn foo() { | ||
return (_, n) => print("Adding foo to", n); | ||
} | ||
fn bar() { | ||
return (_, n) => print("Adding bar to", n); | ||
} | ||
|
||
@foo() @bar() fn testing() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
let { entries } = require("../src/assets/std"); | ||
|
||
let tbl = { | ||
a: 1, | ||
b: true, | ||
c: "x" | ||
}; | ||
|
||
// For-each | ||
for (k, v) in entries(tbl) { | ||
print(k, v); | ||
} | ||
|
||
// Range based for | ||
for i in 1..4 { | ||
print(i); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Example of OOP possible uses with std | ||
let { abstract, entries, mixin, trait, impl } = require("../src/assets/std"); | ||
|
||
// Simple abstract class example. | ||
class SimpleAbstract { | ||
@abstract() fn example(self) {} | ||
fn inherited(self) { | ||
print("This was inherited " ++ self.name); | ||
} | ||
} | ||
|
||
@mixin(SimpleAbstract) | ||
class Simple { | ||
fn example(self) { | ||
print("Won't blow."); | ||
} | ||
fn run() { | ||
let example = Simple { name: "Simple example" }; | ||
example.example(); | ||
example.inherited(); | ||
} | ||
} | ||
Simple::run(); | ||
|
||
// Trait example | ||
@trait() | ||
class TraitLike { | ||
fn foo(self) {} | ||
} | ||
|
||
@impl(TraitLike) | ||
class Implementor { | ||
fn me(self) { | ||
return "Implementor"; | ||
} | ||
fn foo(self) { | ||
print("The foo be like: " ++ self.me()); | ||
} | ||
} | ||
|
||
// Mixin examples | ||
@mixin(Implementor) | ||
class Child { | ||
fn me(self) { | ||
return "The child"; | ||
} | ||
} | ||
|
||
class BeMe { | ||
fn bar(self) { | ||
return "Amogus"; | ||
} | ||
} | ||
|
||
@mixin(BeMe) | ||
@mixin(Child) | ||
class MonsterJack { | ||
fn me(self) { | ||
return "Sus town? " ++ self.bar(); | ||
} | ||
} | ||
|
||
let child = Child {}; | ||
let imp = Implementor {}; | ||
let monster = MonsterJack {}; | ||
imp.foo(); | ||
child.foo(); | ||
monster.foo(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.