Tag:ownership

  • How does NFT play? Why does cross attract much attention? (upper)

    Time:2021-12-25

    In 2020, in addition to defi, which has been popular for more than half a year, NFT is the brightest in the market. 2021 is the first year of NFT. In this issue, we will explain NFT in detail in the form of two articles. This paper introduces some necessary knowledge of NFT to help […]

  • Rust’s basic notes on ownership

    Time:2021-12-7

    Write in front Ownership system is the most unique and attractive feature of rust. Rust also relies on this feature to achieve his biggest goal: memory security. All rust developers should understand it in detail.What a strong flavor of translation. Indeed, I mainly rely on official documents (written clearly and in detail) to learn rust. […]

  • On references and borrowing of rust basic notes

    Time:2021-12-6

    Borrowing Let’s start with a code: fn foo(v1: Vec<i32>, v2: Vec<i32>) -> (Vec<i32>, Vec<i32>, i32) { // do stuff with v1 and v2 // hand back ownership, and the result of our function (v1, v2, 42) } let v1=vec![1, 2, 3]; let v2=vec![1, 2, 3]; let (v1, v2, answer) =foo(v1, v2); If you have to […]

  • Rust basic notes: closures

    Time:2021-12-2

    grammar Closure looks like this: let plus_one = |x: i32| x + 1; assert_eq!(2, plus_one(1)); First create a binding plus_ One, and then assign it to a closure. The body is an expression. Note that {} is also an expression. It can also be written like this: let plus_two = |x| { let mut result: […]

  • Variable ownership type

    Time:2021-11-19

    It’s actually a question and answer post. The official answers too many questions and doesn’t want to answer them,Look at the source code of the add method of string. See a piece of code that is a little confused. Record it. The following is a simple example #[derive(Debug)] struct B { name:String } impl B […]

  • Rust programming video tutorial (Advanced) – 005_ 3 values in closure capture environment

    Time:2021-11-11

    Video address Headline address:https://www.ixigua.com/i677586170644791348…Station B address:https://www.bilibili.com/video/av81202308/ Explanation content 1. Closures capture values in the environment fn main() { let x = 4; let equal_ to_ x = |z| z == x; // Capture values in the environment let y = 4; assert!(equal_to_x(y)); } Closures can capture their environment in three ways. They correspond to the […]

  • Rust programming video tutorial (Advanced) – 018_ 1 Introduction to mutex

    Time:2021-10-5

    Video address Headline address:https://www.ixigua.com/i677586170644791348…Station B address:https://www.bilibili.com/video/av81202308/ Source address GitHub address:https://github.com/anonymousGiga/learn_rus… Explanation content 1. The channel in any programming language is similar to the single ownership method, that is, once a value is transmitted to the channel, the (sender) will no longer be able to use the value; Shared memory is similar to multi ownership, that […]

  • A 30 minute introduction to rust

    Time:2021-10-3

    I recently submitted a proposal to rust’s document. An important part of my whole proposal is a brief and brief introduction to those who may have heard of rust so that they can determine whether rust is suitable for them. A few days ago, I saw a wonderful speech and thought it could be a […]

  • Rust programming video tutorial (Advanced) – 017_ 2 messaging 2

    Time:2021-9-12

    Video address Headline address:https://www.ixigua.com/i677586170644791348…Station B address:https://www.bilibili.com/video/av81202308/ Source address GitHub address:https://github.com/anonymousGiga/learn_rus… Explanation content 1. Channel and ownership transfer(1) Example: use std::thread; use std::sync::mpsc; fn main() { let (tx, rx) = mpsc::channel(); thread::spawn(move || { let val = String::from(“hi”); tx.send(val).unwrap(); println! (“val is {}”, val);// Error, Val cannot be used here because the ownership of Val has […]

  • Rust ownership

    Time:2021-8-31

    As a java developer, everything I know about memory allocation is handled by some processes called garbage collection. This is the problem of the JVM, not mine.So when I openRust BookI became a little worried when I saw that rust had no garbage collection mechanism. Should the responsibility for dealing with memory management rest on […]

  • Rust from pit to soil – pit – string compared to str

    Time:2021-8-30

    String compared to str Rust String Rust str When we first came into contact with rust, we may not be very clear about the relationship and difference between string and STR, so that we are not sure which type to use when writing functions. This paper mainly expounds this problem. Rust’s official documents areStringIn the […]

  • 034 rust book of the dead for VEC to implement drain

    Time:2021-8-24

    introduce The videos recorded in this series are mainly put on station BRust dead book learning video The source code information related to rust dead book is ingithub.com/anonymousGiga/Rustonomi… Details Drain is a collection API that removes the ownership of the data in the container without occupying the container itself. We can claim ownership of all […]