tweedegolf / teach-rs Goto Github PK
View Code? Open in Web Editor NEWA modular, reusable university course for Rust
Home Page: https://teach-rs.trifectatech.org
License: Creative Commons Attribution Share Alike 4.0 International
A modular, reusable university course for Rust
Home Page: https://teach-rs.trifectatech.org
License: Creative Commons Attribution Share Alike 4.0 International
The question states:
Replacing the implementation of deref with self.as_ref() results in a stack overflow when running an unoptimized version. Why? (Hint: deref coercion)
But actually self.as_ref()
does not cause stack overflow: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9ce74e7edda0542dbf20c04f521b2879.
Not sure if I misunderstand something here.
PS: I cannot give a link to above quote directly because the book's website is broken: https://teach-rs.trifectatech.org/full .
Add content on Web Assembly
Best would be to contribute it directly to the restructure
branch while it's still unmerged. There's a file on that branch where the content could be added: https://github.com/tweedegolf/101-rs/blob/restructure/slides/D-rust-for-web/wasm.md
The text says:
You've probably duplicated a lot of code in exercise 2.4.1.F. We can reduce the boilerplate by defining an empty trait:
trait LocalStorageVecIndex {}
First, implement this trait for usize, RangeTo, RangeFrom, and Range.
Next, replace the multiple implementations of Index with a single implementation. In English:
"For each type T, I and constant N of type usize, implement Index for LocalStorageVec<T, N>, where I implements LocalStorageVecIndex and [T] implements Index"
But it seems the trait bound LocalStorageVecIndex
on I
is unnecessary. Removing it also works, e.g.:
impl<T, I, const N: usize> std::ops::Index<I> for LocalStorageVec<T, N>
where
[T]: std::ops::Index<I>,
{
type Output = <[T] as std::ops::Index<I>>::Output;
fn index(&self, index: I) -> &Self::Output {
self.as_ref().index(index)
}
}
or
impl<T, const N: usize, I> std::ops::Index<I> for LocalStorageVec<T, N>
where
I: std::slice::SliceIndex<[T]>,
{
type Output = I::Output;
fn index(&self, index: I) -> &Self::Output {
self.as_ref().index(index)
}
}
Both compile and run without error.
Add content on the sqlx
crate with Postgres
Best would be to contribute it directly to the restructure
branch while it's still unmerged. There's a file on that branch where the content could be added: https://github.com/tweedegolf/101-rs/blob/restructure/slides/D-rust-for-web/sqlx.md
Hi, awesome work! When I recorded my video based on your slides this morning I noticed something that didn't look right.
In this example in slides/slides.md:
fn sum(data: &[i32]) -> i32 { /* ... */ }
fn get_v_arr() -> &'static [i32] {
&[0, 1, 2, 3, 4, 5, 6]
}
fn get_v_vec() -> &'static [i32] {
&vec![0, 1, 2, 3, 4, 5, 6]
}
fn main() {
let all = sum(get_v_arr());
let all_vec = sum(get_v_vec());
}
There is a compile error:
error[E0515]: cannot return reference to temporary value
--> src/main.rs:10:5
|
10 | &vec![0, 1, 2, 3, 4, 5, 6]
| ^-------------------------
| ||
| |temporary value created here
| returns a reference to data owned by the current function
I don't think there is a way to do what we are trying to do here (create a Vec as a literal and expect it to have static lfetime) - I think this example should be edited to mention array literals only.
Content about:
std::sync::atomic::Ordering
Best would be to contribute it directly to the restructure
branch while it's still unmerged. There's a file on that branch where the content could be added: https://github.com/tweedegolf/101-rs/blob/restructure/slides/C-multitasking/ordering.md
Content about:
futures::lock
futures::channel
Stream
& Sync
AsyncRead
& AsyncWrite
Best would be to contribute it directly to the restructure
branch while it's still unmerged. There's a file on that branch where the content could be added: https://github.com/tweedegolf/101-rs/blob/restructure/slides/C-multitasking/ordering.md
Revise current content and add sections on future ideas and roadmap
impl CoffeeMachine {
fn insert_money(self) -> CoffeeMachine {
println!("Money inserted!");
self.insert_money()
}
}
=> self.into_state() instead of self.insert_money() to prevent recursion
exercises/A1/2-move-semantics/01.rs
should compile as is, but this is not true, as there is one mut
missing.exercises/A1/2-move-semantics/src/main.rs
Slide 21: In the subheading, you probably mean 'Structs' instead of 'Enums'?
exercises/A2/4-boxed-data/src/main.rs:102 “If you have time let” should be “If you have time left”
exercises/A2/4-boxed-data/src/main.rs uses a different syntax ('///') instead of ('//') to explain the exercise
The index page is actually fine, but you cannot access the book section for any of the tracks (screenshot bellow, same result on Firefox, Chromium and Vivaldi). Download links for the exercises work fine though. Anyway, interesting project, I see how it could be a great resource for anyone looking to learn or teach Rust, so thanks for the work! 😊
Content about:
Cell
RefCell
Best would be to contribute it directly to the restructure branch while it's still unmerged. There's a file on that branch where the content could be added: https://github.com/tweedegolf/101-rs/blob/restructure/slides/A-foundations/interior-mutability.md
The file https://github.com/tweedegolf/teach-rs/blob/main/content/mods/B-crate-engineering/topics/testing/exercises/fizzbuzz/description.md is empty.
The content seems to have been deleted in cb6390e
Once we've piloted a module, we should describe the lecture and tutorial formats in more detail, in order for other users of this course to get a better understanding of what we suggest is a good way to provide the content to the students.
Add content on the following topics:
Box
, Vec
and String
being smart pointersRc
Drop
Deref
& DerefMut
Deref
coercionBest would be to contribute it directly to the restructure branch while it's still unmerged. There's a file on that branch where the content could be added: https://github.com/tweedegolf/101-rs/blob/restructure/slides/A-foundations/smart-pointers.md
We decided to move teach-rs
to the newly setup non-profit Trifecta Tech Foundation. As such, this repo will be moved under the (trifectatechfoundation)[https://github.com/trifectatechfoundation] github org.
The new repo will thus reside at https://github.com/trifectatechfoundation/teach-rs (this link redirects back to tweedegolf/teach-rs until migration is done).
This change is set to happen before the end of this week
This may be deliberate, but I have noticed that there is a wide variation in the amount of time some of the exercises take. If it is deliberate, maybe it's worth providing some notes so that lecturers can judge when and how to set the work.
Most of the questions seemed to take me 10-30 minutes to complete, but local storage vec took me about 4 hours (see videos part 1 and part 2) and quizzer took me 4h 40 minutes (see video). Admittedly, I am putting in extra time to write robust tests, but even without that these would have taken me a long time.
What do you think about adding support for images / other static files in exercise descriptions?
Or is this already supported somehow?
Usecase: I am working on an exercise for wasm and I would like to show an image of the result in the exercise description (of course, it also would be cool to embed some wasm animation).
Add content on NodeJS interoperability
Best would be to contribute it directly to the restructure
branch while it's still unmerged. There's a file on that branch where the content could be added: https://github.com/tweedegolf/101-rs/blob/restructure/slides/D-rust-for-web/nodejs-interop.md
Hey, I decided to look through the Course Material and have some questions and comments which hopefully can help the course forward. Overal I agree with most of the structure.
What is the actual target audience of the course? Is it targeting first year's students or students later in their university life? My current impression is that is trying to target both, which is fine but is probably quite a lot more difficult.
To deal with these differences in the audience experience, it may be interesting to provide a block with most programming syntax and semantics sections with 4-5 tabs. This should try to explain it which the readers specific context and give the professors good resources depending on the context at the university.
One tab should explain the concept as if the reader has no programming experience, others should explain it as if the reader is coming from a specific programming language. As far as I know the most common languages to learn first at university are C, Python, Java and JavaScript. We can compare basic concepts to how they are in those languages.
The A1 module mostly seems fine to me. One of the parts I maybe agree a bit less with is the Move Semantics. Personally, I would take this chance to explain the rationale for the Borrow Checker and also explain the Drop semantics (not the Drop trait). I feel like most people would agree this is one of the major mechanisms that sets rust apart from other programming languages and having people familiar with it seems like something you want to do as soon as possible. Later you could link back onto this and explain things in a little more detail. Meanwhile students may connect some dots and detect some patterns themselves.
Some others small things:
rustc --explain
is really usefulThis is probably the module I have the most comments about.
const
contexts.macro_rules!
since these are widely usedMaybe, it is an idea to have an A0 module that is specifically for universities trying to use Rust as their intro to programming class. This may be out of the scope of this project, let me know.
This module can explain some of the more general and basic programming concepts. This could cover motivations for items and introduce working code without to much explanation as to what they are. Providing a lot of space for the student to infer their own patterns. I need to do more research into how other courses do this, but right now some of the items I think it should introduce are:
I think it will be very difficult to balance time and what to explain where.
I would love to help writing parts of this course. I would love to hear your opinions on these items and if you agree with some, I can send a PR with those changes. Also, if you would like me to look into some specifics let me know. If you would like to have me start writing on some topic, also let me know. Again, would love to help.
This tracks the progress of the A0 module, which aims to help bridge the gap for two target groups to move onto A1. The groups that are targeted:
This should really represent an optional course that can be included in specific situations. It could serve as a resource for students or provide exercises to study specific low-level concepts.
This was proposed and discussed in #18.
This is a list of things this module should aim to teach. This is not necessarily ordered.
The slides on a specific concept should focus the rough structure:
The module contains many small and rewarding exercises to teach. All of these exercise should be on the Rust Playground and try to really focus on a specific concept per time.
Box
and Vec
but nothing else.We currently have no apt introduction to the (design) goals of Rust. Add a slides that covering the following topic:
Best would be to contribute it directly to the restructure
branch while it's still unmerged. There's a file on that branch where the content could be added: https://github.com/tweedegolf/101-rs/blob/restructure/slides/A-foundations/why-rust.md
Rust 101 is meant to be multi purpose. Therefore, we define a set of different learning tracks consisting of several modules of which we define modules and subjects their content is dependent on.
As a start, we can define the following tracks:
We also explore the possiblity of setting up a track that uses Rust as a first programming language. See #25
For each module, add references to further reading material
I was talking with @dudo50 about solution for the exercise and we are not sure what should be a correct output
Content about some tools that can be used to monitor the code quality
cargo audit
cargo vet
cargo fuzz
cargo udeps
Best would be to contribute it directly to the restructure branch while it's still unmerged. There's a file on that branch where the content could be added: https://github.com/tweedegolf/101-rs/blob/restructure/slides/B-crate-engineering/tools.md
Currently, modmod builds a NodeJS package that uses Slidev to create slideshows out of markdown files. Being a Rust course, it would be nice to depend only on Rust-based tooling, and therefore swap out Slidev for something Rust based.
What we need in a tool:
After dogfooding a bit, here's what I think would improve modmod a lot:
"rust-analyzer.linkedProjects"
) and recommended extensionsContent about:
Best would be to contribute it directly to the restructure
branch while it's still unmerged. There's a file on that branch where the content could be added: https://github.com/tweedegolf/101-rs/blob/restructure/slides/B-crate-engineering/macros.md
To allow teachers to more easily get started with Rust 101, add a teacher's companion to the course. The teacher's companion should describe which modules can be used for different situations and target audiences, and describes per module how it should be taught, how much time we estimate the module takes, and where to find background information on the module subjects.
Add guidelines on how to contribute to this project.
Add content introducing multithreading as a concept
Best would be to contribute it directly to the restructure
branch while it's still unmerged. There's a file on that branch where the content could be added: https://github.com/tweedegolf/101-rs/blob/restructure/slides/C-multitasking/intro.md
compilation of the example on the slide fails... line 6 : replacing "rhs : Self" with "rhs : u32" makes it work.
Content about
Fn
, FnMut
, FnOnce
, fn
Best would be to contribute it directly to the restructure branch while it's still unmerged. There's a file on that branch where the content could be added: https://github.com/tweedegolf/101-rs/blob/restructure/slides/A-foundations/closures.md
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.