@@ -10,6 +10,70 @@ Allows PipeScript to generate Rust.
1010
1111Multiline comments with /* {}* / will be treated as blocks of PipeScript.
1212
13+ ---
14+ ### Examples
15+ #### EXAMPLE 1
16+ ``` PowerShell
17+ $HelloWorldRust = HelloWorld_Rust.rs template '
18+ fn main() {
19+ let msg = /*{param($msg = ''hello world'') "`"$msg`""}*/ ;
20+ println!("{}",msg);
21+ }
22+ '
23+ "$HelloWorldRust"
24+ ```
25+
26+ #### EXAMPLE 2
27+ ``` PowerShell
28+ $HelloWorldRust = HelloWorld_Rust.rs template '
29+ $HelloWorld = {param([Alias('msg')]$message = "Hello world") "`"$message`""}
30+ fn main() {
31+ let msg = /*{param($msg = ''hello world'') "`"$msg`""}*/ ;
32+ println!("{}",msg);
33+ }
34+ '
35+ ```
36+ $HelloWorldRust.Evaluate('hi')
37+ $HelloWorldRust.Save(@{Message='Hello'}) |
38+ Foreach-Object {
39+ $file = $_
40+ if (Get-Command rustc -commandType Application) {
41+ $null = rustc $file.FullName
42+ & ".\$ ($file.Name.Replace($file.Extension, '.exe'))"
43+ } else {
44+ Write-Error "Go install Rust"
45+ }
46+ }
47+ #### EXAMPLE 3
48+ ``` PowerShell
49+ '
50+ fn main() {
51+ let msg = /*{param($msg = ''hello world'') "`"$msg`""}*/ ;
52+ println!("{}",msg);
53+ }
54+ ' | Set-Content .\HelloWorld_Rust.ps.rs
55+ ```
56+ Invoke-PipeScript .\HelloWorld_Rust.ps.rs
57+ #### EXAMPLE 4
58+ ``` PowerShell
59+ $HelloWorld = {param([Alias('msg')]$message = "Hello world") "`"$message`""}
60+ "
61+ fn main() {
62+ let msg = /*{$HelloWorld}*/ ;
63+ println!(`"{}`",msg);
64+ }
65+ " | Set-Content .\HelloWorld_Rust.ps1.rs
66+ ```
67+ Invoke-PipeScript .\HelloWorld_Rust.ps1.rs -Parameter @{message='hi'} |
68+ Foreach-Object {
69+ $file = $_
70+ if (Get-Command rustc -commandType Application) {
71+ $null = rustc $file.FullName
72+ & ".\$ ($file.Name.Replace($file.Extension, '.exe'))"
73+ } else {
74+ Write-Error "Go install Rust"
75+ }
76+ }
1377---
1478### Parameters
1579#### ** CommandInfo**
0 commit comments