Skip to content

Instantly share code, notes, and snippets.

using System;
namespace Crash
{
public record class Test
{
public override string ToString()
{
return "Crash";
}
using System;
namespace Option
{
public abstract class Option
{
public static Option Wrap<T>(T value)
where T : class
{
if(ReferenceEquals(value, null))
using System;
namespace Test
{
public abstract class Expr {}
public record class Add(Expr left, Expr right) : Expr {}
public record class Sub(Expr left, Expr right) : Expr {}
public record class Mul(Expr left, Expr right) : Expr {}
public record class Div(Expr left, Expr right) : Expr {}
public record class Val(decimal value) : Expr {}
var xs = from y in ys
where y % 2 == 0
let x = y * 2 + 1
select y;
var someResult = builder.AppendLine("Hello, world!")
.AppendLine("This is a test!");
var xs = from y in ys
where y % 2 == 0
let x = y * 2 + 1
select y;
var someResult = builder.AppendLine("Hello, world!")
.AppendLine("This is a test!");
Imports AW
Module Bot
' Variable to hold a reference to the bot instance.
Dim _instance As Instance
' Variable to hold a reference to avatar add handler.
Dim _avatarAddHandler As InstanceEventHandler
Sub Main()
using System;
using System.Collections.Generic;
using System.Linq;
using System.Math;
public class Point(double x, double y)
{
public double X { get; } = x;
public double Y { get; } = y;
extern "C" fn foo()
{
println("Hello, world!");
}
struct Bar
{
Foo: extern "C" fn()
}
struct Blorp
{
bar: ~int
}
impl Blorp
{
fn wrap(value: ~int) -> Blorp
{
Blorp { bar: value }
@Mr-Byte
Mr-Byte / linq.rs
Last active August 13, 2017 18:00
Proof of concept macro to implement LINQ syntax in rust.
macro_rules! query(
(from $v:ident in $c:ident $(where $mw:expr)* select $ms:expr) =>
($c.filter_mapped(|&$v| if(true $(&& $mw)*) { Some($ms) } else { None }))
)
fn main()
{
let nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let result1 = query!(from x in nums select x * 2);