• Stars
    star
    145
  • Rank 254,144 (Top 6 %)
  • Language
  • Created over 5 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Personal notes while learning Rust. Mainly documenting pain points along the way.

Rust Bumps

This is a collection of notes I have on sharp edges I've encountered in my journey to learn Rust, in hopes that I can use them in the future to target contributions to Rust proper, or to share with others who might be interested.

Contribution Process

It wasn't immediately clear what the process of actually contributing to Rust proper is.

Solutions

I went to #beginners in the Rust discourse, and they pointed me at the forum, where I'd need to bring it up, try and get some buy-in around my change concept, then put together an RFC when enough(?) people have shown interest, and then finally that RFC would point to an implementation.

Builders

The builder pattern is super common in Rust. Almost obnoxiously so. To the point where I wonder if Rust should have some sort of first-class support or new language feature that largely obsoletes the need for the pattern.

Solutions

In general the pattern is often replaced by things like variadic functions or ad-hoc option arguments in other languages.

This isn't a terrible pattern, but even going as far as introducing https://crates.io/crates/derive_builder into the language or into the Book would be nice.

Multi-type errors

The book doesn't really cover a pretty basic case in earnest: the situation where you have multiple different error returns and you want to use ?.

Solutions

Establishing an error-definition pattern a-la https://crates.io/crates/failure in the Book would be super helpful, if not integrating failure itself.

Update: I'm supposed to use failure, not error-chain, per @ag_dubs. SIGH

Update: The plot thickens! https://twitter.com/hoodie_de/status/1135192684916879360 claims I should not be returning failure::Error from public APIs but this is not clear at all and I'm not sure what the expected alternative is.

Returning iterators

Iterators are super duper useful! Infortunately, it's super hard to figure out how to -return- them from functions. The compiler errors when you first try to do this are incredibly opaque and confusing.

Solution

It turns out these days, you have -> impl Iterator which makes this work, but this was not very obvious and the compiler errors were SUPER CONFUSING about how to fix this. It might go a long way to have the compiler be aware of at least the Iterator case. Those compiler messages, wwhoo.

WTF is AsRef?

I kept seeing this AsRef stuff while working with Path-related functionality and didn't really understand why folks were doing that instead of path: &Path in function signatures.

Solutions

This isn't really covered in the Book, and maybe it should. A friend proceeded to explain the use and intent: It's used as a perf-cheap version of From to convert from one immutable ref to another immutable ref. In this particular case, it was being used so you could pass Paths, PathBufs, or strings into the function and have it work with any of those types.

It would be nice to make a note in the Book about this being a convention, or becoming one?

Weird File API

The File-related APIs are really strange and factored in such a way that I had a really hard time finding what I needed, compared to the relatively flat fs module in Node.js.

I think the biggest pain is that some things seem to live in fs::, some in io:: and others in fs::File, and it wasn't clear when one vs the other was used. The toplevel fs:: utilities are actually pretty handy, though!

Solutions

idk. Changing this fundamentally would have a huge impact, unfortunately, and Rust is very stability-oriented these days. I kinda wish there were a simpler, higher-level, zero-cost crate for doing these things, optionally with Futures, and for the fs and io stuff to largely be considered "internal use only" building blocks, if even that. I just plain don't like it and find it hard to work with. Maybe Tokio is the answer, once it's updated with [email protected]?

Literally no chown?

So the fs API has literally no chown functionality. I know it's pretty niche, but I needed it!

Solutions

This is exposed through direct bindings by nix. There's also a higher-level chownr crate by yours truly that does the recursive bit.

Everyone uses extern crate

...but you're supposed to just use use. This is mostly an annoyance because everyone's docs are outdated and still refer people to importing using this. As an additional note, a lot of places combine this statement with #![macro_use] when importing macros.

Solutions

Highlighting that extern crate isn't used anymore, in the Book, might be super helpful here. The rest is just waiting out the ecosystem. I'm not really sure what the actual expected alternative to #![macro_use] is supposed to be, but I had some luck directly use-ing the macro into my scope like a function? So a macro named foo in crate bar would be imported with use bar::foo; and then the macro seemed to work...

No cargo version built-in

Coming from Node, this feels like a sharp corner: I have to manually edit Cargo.toml, change the version, run cargo build to update the Cargo.lock so I don't end up with a random diff, then I have to manually git ci -a -m 'vX.Y.Z', git tag -a vX.Y.Z, fill in a message, git push --follow-tags, and then cargo publish. Just for a basic release. I'm used to at least having a baseline of npm version patch && git push --follow-tags && npm pub.

Solution

Having a baseline cargo version built in would go a long way towards making publishing as a newbie a smoother process.

No nyc equivalent for coverage

There's no single coverage tool you can just install that integrates with cargo test and gives useful coverage feedback in the command line, works with coveralls/codecov, etc. The best you get is something as described in this 3-year-old forum thread which... honestly I'm not going to bother because this is an immense amount of fucking around with stuff just to get my percentages?

I'm so used to having nyc available :()

Solution

Rust -really- needs an nyc port.

More Repositories

1

npx

execute npm package binaries (moved)
JavaScript
2,625
star
2

miette

Fancy extension for std::error::Error with pretty, detailed diagnostic printing.
Rust
2,005
star
3

big-brain

Utility AI library for the Bevy game engine
Rust
1,032
star
4

cacache-rs

A high-performance, concurrent, content-addressable disk cache, with support for both sync and async APIs. 💩💵 but for your 🦀
Rust
529
star
5

cipm

standalone ci-oriented package installer for npm projects (moved)
JavaScript
400
star
6

make-fetch-happen

Get in loser, we're making requests!
JavaScript
384
star
7

pacote

programmatic npm package and metadata downloader (moved!)
JavaScript
280
star
8

cacache

💩💵 but for your data. If you've got the hash, we've got the cache ™ (moved)
JavaScript
240
star
9

chanl

Portable channel-based concurrency for Common Lisp
Common Lisp
164
star
10

mona

Composable parsing for JavaScript
JavaScript
152
star
11

maybe-hugs

Polyglot implementations of conditional hugging
OCaml
114
star
12

proposal-as-patterns

`as` destructuring patterns
105
star
13

sheeple

Cheeky prototypes for Common Lisp
Common Lisp
99
star
14

pattycake

playground for pattern matching api
JavaScript
98
star
15

ssri

Standard Subresource Integrity library for Node.js
JavaScript
82
star
16

json-parse-better-errors

get better errors
JavaScript
67
star
17

squirl

Common Lisp port of the Chipmunk 2d physics library
Common Lisp
53
star
18

supports-color

Detects whether a terminal supports color, and gives details about that support
Rust
42
star
19

figgy-pudding

Cascading, controlled-visibility options object management.
JavaScript
39
star
20

genfun

Prototype-friendly multimethods for JavaScript.
JavaScript
38
star
21

ssri-rs

Rusty implementation of Subresource Integrity
Rust
38
star
22

can.viewify

require() mustache and ejs modules as compiled CanJS views
JavaScript
37
star
23

protoduck

Duck typing for the most serious of ducks.
JavaScript
35
star
24

chillax

CouchDB abstraction layer for Common Lisp
Common Lisp
34
star
25

cl-openal

Common Lisp bindings for the OpenAL audio library.
Common Lisp
34
star
26

conserv

Common Lisp
31
star
27

memento-mori

Robustness through actors, for Common Lisp
Common Lisp
31
star
28

talks

Notes and slides for all my talks
JavaScript
26
star
29

until-it-dies

A batteries-included game engine.
Common Lisp
25
star
30

supports-hyperlinks

Detect whether the current terminal supports rendering hyperlinks
Rust
25
star
31

matrix-curious

FAQ and resources for those curious about joining the Matrix network!
23
star
32

sykobot

An IRC bot from another universe. No, really.
Common Lisp
21
star
33

turron

Rusty NuGet client
Rust
20
star
34

npm-pick-manifest

Standard manifest picker/semver resolver for npm
JavaScript
20
star
35

cl-ffmpeg

CFFI bindings for FFMPEG
Common Lisp
19
star
36

proposal-collection-literals

[WITHDRAWN] tc39 proposal for custom collection literals
18
star
37

cl-devil

Common Lisp bindings for DevIL
Common Lisp
16
star
38

okimdone

tells you when it's done
Shell
15
star
39

srisum-rs

Compute and check subresource integrity digests.
Rust
14
star
40

thisdiagnostic

Add nice user-facing diagnostics to your errors without being weird about it.
Rust
14
star
41

is_ci

Super lightweight and dead-simple CI detection.
Rust
12
star
42

common-worm

A simple, hackish version of the classic snake game, written in Common Lisp
Common Lisp
12
star
43

supports-unicode

Detects whether a terminal supports unicode.
Rust
12
star
44

nanotubes

Fancy websocket wrapper for Rust
Rust
12
star
45

srisum

Compute and check Subresource Integrity digests.
JavaScript
11
star
46

DWG.Directories

Standard directories for .NET
10
star
47

cadr

content-addressable filesystem snapshots
JavaScript
10
star
48

protocols

Multi-type protocol-based polymorphism
JavaScript
10
star
49

cl-speedy-queue

Lightweight, optimized queue implementation for CL
Common Lisp
9
star
50

playwright

Like Erlang, but not
JavaScript
9
star
51

sykosomatic

Cooperative storytelling
Common Lisp
7
star
52

cond

Restartable error handling system for JavaScript
JavaScript
7
star
53

destealify

Browserify transform for processing StealJS modules
JavaScript
7
star
54

bacon-browser

Utility library for higher-level, declarative interaction with various bits of browser-level events and features.
JavaScript
7
star
55

sykosomatic-legacy

text-based online game engine
Common Lisp
7
star
56

shepherdb

A Sheeple-based persistent object store.
Common Lisp
6
star
57

clutter

nothing to see here
Common Lisp
6
star
58

facile

CouchDB view server for Factor
Factor
6
star
59

fl-protocols

fantasy-land specification bridge for @zkat/protocols
JavaScript
6
star
60

electron-collider

Rust
5
star
61

my-precious

a local package archive, of our own
JavaScript
5
star
62

checksum-stream

Calculates and/or checks data coming through a stream and emits the digest before stream end.
JavaScript
5
star
63

cl-form

Generic form validation utility for CL
Common Lisp
5
star
64

common-brick

Breakout clone with "realistic" physics.
Common Lisp
4
star
65

surf-middleware-cache

http caching middleware for the Surf http client
Rust
4
star
66

specificity

Runnable specifications for Common Lisp
4
star
67

friendfavor

Find out what your friends think of something -- or someone!
Common Lisp
4
star
68

shortening

The personal URL shortener.
Common Lisp
3
star
69

kallisti

kallisti
Rust
3
star
70

clutterscript

Pay this no heed, I'm just learning stuff.
JavaScript
3
star
71

cl-event2

libevent2 bindings for Common Lisp
Common Lisp
3
star
72

yashmup

Toy project -- writing a shmup in CL
Common Lisp
3
star
73

test

just a place to test random github shit
2
star
74

marina

placeholder for programming language
2
star
75

mona-csv

simple mona-based csv parser
JavaScript
1
star
76

proto

Alternative to JavaScript's `new`.
Makefile
1
star
77

dynvar

Dynamic variables for JS
JavaScript
1
star
78

protoduck-fl

fantasy-land specification bridge for protoduck
JavaScript
1
star
79

mona-json

mona-based JSON parser
JavaScript
1
star
80

mona-strings

String parsers for mona
JavaScript
1
star
81

logloc

Adds source location to console loggers
JavaScript
1
star
82

zkat

it me
1
star
83

node-otp

The Node.js Open Telecom Platform
1
star
84

fetch-cache

Cache API implementation + protocol
JavaScript
1
star
85

tswrp

JavaScript
1
star
86

chownr-rs

Like chown -r for Rust
Rust
1
star
87

presentations

various presentations
JavaScript
1
star
88

storychat

~~~ tell me a story <3 with your words ~~~
JavaScript
1
star
89

mona-combinators

Parser combinators for mona
JavaScript
1
star
90

fig-roll

rolls up your configs into a nice figgy pudding
1
star
91

chatoid

Toy chatroom using webrtc
JavaScript
1
star
92

ironsworn-mechanics

Various support utilities and some custom rendering for mechanics in Ironsworn-family games (Starforged, Sundered Isles, etc).
TypeScript
1
star
93

zkat.github.io

Web sight
TypeScript
1
star