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
// This does not work without the move marker. The reason for that is that the lifetime for `a` | |
// only covers the scope of the outer function, which does not extend to the scope of the inner | |
// function, which is returned from the outer function. | |
fn main() { | |
let x = |a| move |b| a + b; | |
let y = x(5); | |
let z = y(5); | |
println!("{}", z); // prints 10 | |
} |
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
/Closes the window and commits the order to the database | |
private void btnComplete_Click(object sender, EventArgs e) | |
{ | |
using(var conn = new OleDbConnection(Utilities.CONNECTION_STRING)) | |
{ | |
OleDbCommand cmd = new OleDbCommand | |
("INSERT INTO tblOrders ([OrdersProducts],[OrdersSoldTo],[OrdersTotalPrice])Values(@Products,@Clients,@TotalCost)"); | |
cmd.Connection = conn; | |
conn.Open(); | |
if (conn.State == ConnectionState.Open) |
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 Newtonsoft.Json; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Net; | |
namespace ZC | |
{ | |
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
use std::fmt; | |
use std::ops; | |
trait Distance { | |
type Value; | |
fn to_normal(&self) -> f64; | |
fn from_normal(f64) -> Self::Value; | |
} | |
/// Creates a distance type. |
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::fmt; | |
use std::ops::Add; | |
trait Distance { | |
type Value; | |
fn to_normal(&self) -> f64; | |
fn from_normal(f64) -> Self::Value; | |
} | |
/// This is an attempt at providing a default implementation of the add trait on the Distance trait |
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
enum TestEnum { | |
DataA { f: String, l: String }, | |
DataB { n: String }, | |
} | |
impl std::fmt::Display for TestEnum { | |
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { | |
match self { | |
&TestEnum::DataA { ref f, ref l } => write!(fmt, "{}, {}", l, f), | |
&TestEnum::DataB { ref n } => fmt.write_str(&n), |
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
struct TipResult { | |
amt: f64, | |
tip: f64, | |
} | |
fn main() { | |
let args: Vec<_> = std::env::args().collect(); | |
let tip = match &args[..] { | |
[_, ref amt] => get_tip(amt.parse().ok(), Some(0.15f64)), |
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.Linq; | |
using System.Net; | |
using System.Text.RegularExpressions; | |
namespace Computus | |
{ | |
class Program | |
{ | |
static Regex NodePattern = new Regex(@"<pre>.*?</pre>", RegexOptions.IgnoreCase|RegexOptions.Singleline); |
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; | |
namespace ConsoleApplication2 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var propertyValue = GetValidDecimalInput(); | |
var propertyTax = PropertyAssessment(propertyValue) * 0.0064m; |
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::HashSet; | |
use std::hash::{Hash, Hasher}; | |
use std::collections::hash_state::HashState; | |
fn main() { | |
if let Some(content) = { | |
let args = std::os::args(); | |
if args.len() == 2 { | |
Some(args[1].to_string()) | |
} else { |