This file contains hidden or 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
| model Person { | |
| uid: string(100), | |
| name: string(200), | |
| last_name: string(200), | |
| birth_date: datetime | |
| } | |
| model Book { | |
| name: string(200) | |
| } |
This file contains hidden or 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
| use std::collections::HashMap; | |
| use std::convert::From; | |
| enum JsType { | |
| JsNum(i32), | |
| JsString(String), | |
| JsNullable(Option<Box<JsType>>), | |
| JsObject {data: HashMap<String, JsType>, level: u32} | |
| } |
This file contains hidden or 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
| use std::iter::{Iterator, IntoIterator, FromIterator}; | |
| fn main() { | |
| let v: Vec<i32> = FiveNumbers::new(2,3,5,8,13).into_iter().collect(); | |
| let f = v.iter().cloned().collect::<FiveNumbers>(); | |
| let r: Result<FiveNumbers, ()> = | |
| vec![1,2,3,4,5].into_iter().map(|n| Ok(n)).collect(); | |
| let r2: Result<Vec<i32>, &str> = | |
| f.clone().into_iter().map(|n| Ok(n)).collect(); | |
| let r3: Result<Vec<i32>, &str> = |
This file contains hidden or 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
| #[derive(Clone, Copy)] | |
| enum CellType { | |
| Number(u32), | |
| Bomb, | |
| Empty | |
| } | |
| type InputBoard = [[u8; 8];8]; | |
| type GameBoard = [[CellType; 8];8]; |
This file contains hidden or 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
| use std::collections::HashMap; | |
| use std::rc::Rc; | |
| use std::fmt::Debug; | |
| use std::ops::{Add, Sub}; | |
| #[derive(Debug, Clone)] | |
| pub enum JsValue<T: ToString> { | |
| StaticValue(T), | |
| ResultValue(Box<JsOps>), | |
| } |
This file contains hidden or 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.Collections.Generic; | |
| using System.Linq; | |
| using System.Windows.Forms; | |
| using System.Drawing; | |
| namespace SimpleMinesweeper | |
| { | |
| class Program | |
| { |
This file contains hidden or 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
| #[derive(Debug)] | |
| struct JsFunction<T: JsType, P> { | |
| params_type: PhantomData<P>, | |
| operations: Vec<Box<JsSentence>>, | |
| return_value: Option<T>, | |
| } | |
| impl<S:Borrow<str>> From<S> for JsString { | |
| fn from(value: S) -> JsString { | |
| JsString::new(JsValue::StaticValue(value.borrow().to_string())) |
This file contains hidden or 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
| pub trait IterOps<T, I>: IntoIterator<Item = T> | |
| where I: IntoIterator<Item = T>, | |
| T: PartialEq { | |
| fn intersect(self, other: I) -> Vec<T>; | |
| fn difference(self, other: I) -> Vec<T>; | |
| } | |
| impl<T, I> IterOps<T, I> for I | |
| where I: IntoIterator<Item = T>, | |
| T: PartialEq |
This file contains hidden or 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() { | |
| let mut arr = [3,11,7,89,85,4,39,51,15,9,74,57,60,22,46,48,79,25,72,5,80,27]; | |
| arr.quicksort(); | |
| println!("{:?}", arr); | |
| } | |
| trait Sortable: PartialOrd { | |
| fn quicksort(&mut self); | |
| } |
This file contains hidden or 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
| // Note to self: Remember that traits can store and reference | |
| // a lot of type info related to the types that implemented it. | |
| fn main() { | |
| println!("{:?}", vec![2,4,5,6,8].map(|&n| n * 2)); | |
| println!("{:?}", vec![1,2,3,4,5].fold(0, |acc, &n| acc + n)); | |
| println!("{:?}", vec!["a", "b", "c"].fold_map(|c| c.to_uppercase())); | |
| } | |
| // Basically, for every container C<T> that implements this trait | |
| // we save the information of his current type T, the type N to be |