near / devx

This is the home of NEAR collective developer experience plans and roadmap.
11 stars 0 forks source link

Improve Intro to Rust from docs #159

Open mikedotexe opened 4 years ago

mikedotexe commented 4 years ago

Rust Tutorial Notes and Feedback (https://docs.nearprotocol.com/docs/tutorials/intro-to-rust)

  1. Can a new section called “Dependecies” or “Prerequisites” be created after An Introduction to Rust Smart Contracts? a. All the dependencies and related links or installation instructions, listed across the tutorial, can be grouped under this section. I think it sets the user up for successfully completing the tutorial right at the beginning.
  2. Section: Versioning for this example a. can this be moved at top and grouped with rust installation steps under Perquisites or Dependencies section (new section)? The naming is bit confusing. Looking at the headline I thought it was about versioning the example but it’s really about the dependencies. Keeping dependencies on top gives the learner an opportunity the setup the environment with correct prerequisites before moving further in the tutorial.
  3. Section: Imports and initial code near the top a. this section says that the env in imports is coming from near-sdk-rs however it seems to be coming from near-sdk. Near-sdk-rs is not available in the dependencies. b. The example code just above the text about env import shows “use near_bindgen” however the sample code file (lib.rs) has “use near_sdk”. Near_bindgen does not appear to be a valid module for use.
  4. Section: Our code logic: the struct a. The first line says, “We declare our Counter and impl”. This is a bit confusing as Counter is technically a struct implemented using functions in impl. Can it be changed to something like “the core logic consists of declaring struct and implementing the functions we will invoke on blockchain using impl (e.g. struct Counter and impl Counter in sample code)”? Also, the link for Rust struct can be provided in this section.

Test Results:

  1. Tests successful (cargo test --package rust-counter-tutorial -- --nocapture)
  2. Compilation successful (env 'RUSTFLAGS=-C link-arg=-s' cargo build --target wasm32-unknown-unknown –release)
  3. Successfully called increment, decrement and get_num functions using my wallet account

The instructions were easy to follow and understand.