View list.rs
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
use std::rc::Rc; | |
pub enum List<T> { | |
Node { value: T, next: Rc<List<T>> }, | |
Empty, | |
} | |
impl <T> List<T> { | |
pub fn empty() -> Self { | |
List::Empty |
View iterators2.rs
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
// iterators2.rs | |
// In this exercise, you'll learn some of the unique advantages that iterators | |
// can offer. Follow the steps to complete the exercise. | |
// Execute `rustlings hint iterators2` or use the `hint` watch subcommand for a hint. | |
// Step 1. | |
// Complete the `capitalize_first` function. | |
// "hello" -> "Hello" | |
pub fn capitalize_first(input: &str) -> String { | |
let mut c = input.chars(); |
View errors6.rs
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
// errors6.rs | |
// Using catch-all error types like `Box<dyn error::Error>` isn't recommended | |
// for library code, where callers might want to make decisions based on the | |
// error content, instead of printing it out or propagating it further. Here, | |
// we define a custom error type to make it possible for callers to decide | |
// what to do next when our function returns an error. | |
// Execute `rustlings hint errors6` or use the `hint` watch subcommand for a hint. |
View settings.json
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
{ | |
"$help": "https://aka.ms/terminal-documentation", | |
"$schema": "https://aka.ms/terminal-profiles-schema", | |
"actions": [], | |
"defaultProfile": "{00000000-0000-0000-ba54-000000000002}", | |
"profiles": | |
{ | |
"defaults": | |
{ | |
"antialiasingMode": "cleartype", |
View export.py
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
from math import pi | |
import bpy | |
import os | |
import copy | |
# export to blend file location | |
dirname = os.path.dirname | |
basedir = dirname(dirname(dirname(bpy.data.filepath))) | |
export_dir = os.path.join(basedir, "Assets", "Models") |
View table_test.go
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
package merge | |
import ( | |
"testing" | |
) | |
func TestMergeTables(t *testing.T) { | |
alice := Table[string, *additive]{ | |
"vanilla": add(3), | |
"chocolate": add(5), |
View maybe.go
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
package main | |
import ( | |
"fmt" | |
"unicode/utf8" | |
) | |
type Maybe[T any] struct { | |
val T | |
ok bool |
View union.go
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
package main | |
import ( | |
"fmt" | |
) | |
// Allowed is a constraint that matches specific types | |
type Allowed interface { | |
int | float64 | bool | |
} |
View main.go
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
package main | |
import ( | |
"fmt" | |
) | |
// ref is a reference to a value. A reference can read that | |
// value but not alter it. | |
type ref[V any] struct { | |
v *V |
View merge.go
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
package main | |
import ( | |
"fmt" | |
"strings" | |
) | |
type A int | |
func (a *A) Merge(v *A) error { |
NewerOlder