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
#![feature(proc_macro_hygiene)] | |
use inline_python::python; | |
fn main() { | |
let who = "world"; | |
let n = 5; | |
println!("== 1. Hello World =="); | |
python! { | |
for i in range('n): | |
print(i, "Hello", 'who) |
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
extern crate hello; | |
fn main() { | |
hello::world(); | |
hello::you_can_say(); | |
hello::say(); | |
} |
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
// public function | |
pub fn world() { | |
println!("say world"); | |
} | |
// private_function | |
fn say() { | |
println!("hello world`"); | |
} |
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
fn main() { | |
// 結構 | |
// https://doc.rust-lang.org/rust-by-example/custom_types/structs.html | |
#[derive(Debug)] | |
struct User { | |
username: String, | |
email: String, | |
} |
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
#![feature(vec_remove_item)] | |
fn main() { | |
// vector是一個重新調整size的array(類似c#裡面的list), 他的size在編譯時期 | |
// 是不會知道。但他可以在任何時間增大或減少size, 然後vector只能儲存相同類型的值 | |
// 建立vector的方式 | |
println!("== 1. 建立vector的方式 =="); | |
let v = vec![1, 2, 3]; | |
println!("v => {:?}", 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
// https://learning-rust.github.io/docs/e4.unwrap_and_expect.html | |
use std::collections::HashMap; | |
fn main() { | |
// 範例一 | |
let mut inventory = HashMap::new(); | |
// 設定預設值 | |
let inventory_default = 0; | |
// 加入資料到HashMap | |
inventory.insert(String::from("Notebook"), 10); |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.8.7/polyfill.js"></script> | |
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | |
</head> |
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
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.8.7/polyfill.js"> | |
</script><script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> |
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
using System; | |
namespace aoptest | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var decoratedAPI = LoggerDecorator<IHttpApi>.Create(new HttpApi()); | |
decoratedAPI.Get("https://www.google.com"); |
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
using System; | |
using System.Reflection; | |
using System.Text.Json; | |
namespace Sample.AOPProxy | |
{ | |
public class LoggerDecorator<T> : DispatchProxy | |
{ | |
private T _decorated; | |
public static T Create(T decorated) |
NewerOlder