Skip to content

pdx-cs-rust/examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Examples

Bart Massey 2021

Various small examples from my Rust course. Previously a lot of these were on the playground, but I prefer to have them in a controlled repository now.

  • datatypes/: examples of various datatype thingies
  • structs.rs: struct and enum examples
  • arrays.rs: array and vector examples
  • strings.rs: string and str examples
  • iterators.rs: iterator examples
  • closures.rs: closure examples
  • lifetimes.rs: simple lifetime example
  • rc/: examples with RefCell and Rc
  • readline/: example of readline with error handling
  • error/: example of creating a custom error
  • modules/: example of modules
  • point.rs: example of "methods" and ownership
  • units.rs: example of newtype and deriving
  • patmove.rs: example of ref in patterns
  • result/: example of defining and using Result
  • top.rs: top-n list example using generics
  • sum.rs: generic iterator sum example
  • custom_sum.rs: sum example with custom Sum type
  • addy.rs: trait def/impl example
  • bno-salad.rs: trait salad example from Blandy and Orendorff
  • matmul.rs: example of overloading multiplication for matrices
  • stacks.rs: example defining a stack trait
  • phantom.rs: phantom type example
  • deref.rs: deref trait example
  • from.rs: from / try_from trait example
  • prog.rs, prog2.rs: state machine examples using closures
  • negiter/: example iterator adapter
  • stackcoll/: example fromiterator implementation
  • shuflr/: example iterator implementation
  • seqs.rs: examples with sequence types
  • vecdeque.rs: example of VecDeque usage
  • setimpl.rs: example implementation of HashSet as HashMap
  • rng/: example use of rand crate
  • charcast.rs: character / number casting examples
  • lower.rs: boring character lowercase example
  • stringchars.rs: string ←→ chars conversion examples
  • stdio.rs: stdio usage example
  • debug-macro.rs: declarative macro example
  • square-macro.rs: example of macro argument reuse
  • macro-body-bug.rs: example of syntax issue in macro body
  • debug-macro-rep.rs: example of macro with varargs
  • macro-nargs.rs: example of recursive macro
  • macro-tt.rs: macro token tree example
  • nullptr.rs: null pointer example
  • c++-ffi/: example of FFI between C, C++ and Rust
  • ownership-demo/: example of ownership and borrowing stuff in C and Rust
  • rust-winter2022/: examples from Rust class Winter 2022
  • struct-example.rs: example of Rust struct
  • enum-example.rs: example of Rust enum
  • closure-example.rs: example of Rust closure
  • iterator-example.rs: example of Rust iterator
  • lifetimes-example.rs: example involving Rust lifetimes
  • strref.rs: example involving Rust string clones and copies
  • closures/: closure examples
  • for-demo.rs: example of passing iterators
  • iter-from-fn.rs: example use of iter::from_fn()
  • rev.rs: example for loop with reversed iterator

Releases

No releases published

Packages

No packages published

Languages