Code Monkey home page Code Monkey logo

hello_cargo's Introduction

hello Rust/Cargo

index

其他

  • 一些测试代码(src/test_code/t1.rs)
  • Rust 中的字串处理(src/rs_string)

Usage

build

  • rustc src/study/ownership.rs -o a.out

run

  • ./a.out
  • 编译并运行
    • 以 ownership.rs 文件为例:./run.sh src/study/ownership.rs

知识点 todo

所有权

  • 在堆上创建字符串:let str1 = String::from("hello world")

example app

try my first app in rust

流程

  • 每个事项有一个id和一个名称
  • 当我们新增一个事项,会将其写入todos/pending.todo文件中,这个文件包含了所有“进行中”事项的数组,这个数组使用bincode编码。
  • todos/counter.todo这个文件包含了最新使用的主键id,它是为了给新创建的事项分配一个唯一的id,当新增一个事项时,会将这个数组递增并存入这个文件中。
  • 无论何时,用户标记事项已经完成是,将会将事项从todos/pending.todo中移除,并将其写入到todos/completed.todo文件中,todos/completed.todo中包含了所有的已完成事项的数组。

百坑全书

  • 代码块中的调用语句,“加分号”和“不加分号”返回的结果截然不同
  • 一个rs文件中,如果存在不会调用的函数,可以通过在函数上方添加#[allow(dead_code)]注解或者#[test],让编译器不在提示warning。

参考资料

hello_cargo's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.