rust

Rust开发以太坊智能合约-Parity

我的未来我决定 提交于 2020-03-01 12:27:57
Parity 声称是世界上最快速最轻便的客户端。它用Rust语言写成,可靠性、性能和代码清晰度都有所增强。Parity由Ethcore开发。Ethcore由以太坊基金会的几个会员创建。 网站: https://ethcore.io/parity.html Github: https://github.com/ethcore/parity Gitter聊天: https://gitter.im/ethcore/parity Arch Linux 程序包由Afri Schoedon和quininer进行社群维护。 https://aur.archlinux.org/packages/parity/ (稳定,最新版本) https://aur.archlinux.org/packages/parity-git/ (不稳定,最新开发) 已经有人报告在树莓派2上成功运行了Parity。 如果你希望 高效的 学习以太坊DApp开发,可以访问汇智网提供的 最热门 在线互动教程: 适合区块链新手的以太坊DApp实战入门教程 区块链+IPFS+Node.js+MongoDB+Express去中心化以太坊电商应用开发实战 其他更多内容也可以访问 这个以太坊博客 。 来源: oschina 链接: https://my.oschina.net/u/3837977/blog/1805446

How to avoid multiple mutable borrows of a vector when inserting a value if the vector is empty?

こ雲淡風輕ζ 提交于 2020-03-01 05:17:11
问题 In this github discussion you find this code that draws the ire of the borrow checker: fn main() { let mut vec = vec!(); match vec.first() { None => vec.push(5), Some(v) => unreachable!(), } } I understand why having a mutation while immutable borrows are outstanding is problematic. I assumed that a solution was to explicitly only have one borrow (a mutable one) but it still resulted in my having two borrows, an immutable borrow and then a mutable borrow: fn main() { let mut vec: Vec<i32> =

How to avoid multiple mutable borrows of a vector when inserting a value if the vector is empty?

两盒软妹~` 提交于 2020-03-01 05:16:03
问题 In this github discussion you find this code that draws the ire of the borrow checker: fn main() { let mut vec = vec!(); match vec.first() { None => vec.push(5), Some(v) => unreachable!(), } } I understand why having a mutation while immutable borrows are outstanding is problematic. I assumed that a solution was to explicitly only have one borrow (a mutable one) but it still resulted in my having two borrows, an immutable borrow and then a mutable borrow: fn main() { let mut vec: Vec<i32> =

Rust语言开发基础(五)语言数据类型

拥有回忆 提交于 2020-03-01 03:19:49
一. 基本介绍 虽然是静态类型语言,但是定义变量,不用定义类型,只用关键字声明即可,即用关键字 let ,Rust 有类型推断,用以平衡强大的静态类型和冗长标注类型。 let x = "hello, world!"; let a="foobar"; let b="foo\ bar"; let mut x = vec!["Hello", "world"]; 使用名字叫“vec”的宏(感叹号表示宏),将这个宏绑定到一个叫“x”的变量上。 Rust 更倾向于堆栈分配而不是堆分配:x 被直接放置在堆栈中。然而,Vec<T> 类型是在堆上分配的向量元素的空间。 这个let体现的是Rust中的“所有权”概念。 我们将Rust语言类型分为两种来说明,即基本类型和集合。 二. 基本类型 1.字符和字符串 字符类型 :let a = 'b'; 字符串类型 : let a = "abcdef"; 行类型 : let a = r#abcdef#; 字节字符类型 :let a = b'a'; 字节字符串类型:let a = b"abcdef"; 字节行类型 : let a = br#abcdef#; 前缀b=bite字节, r=row行 \字符串换行符,也是转义字符的标识。 let a = "foobar"; let b = "foo\ bar"; a和b是相等的字符串。 Rust包含2个字符串类型

Should the Copy trait always be implemented if possible?

前提是你 提交于 2020-03-01 01:50:07
问题 You can implement the Copy trait to give the type copy-semantics instead of move-semantics. This can only be done if all its constituent elements (each factor of a product type, or each factor of each variant of a sum-type) are also Copy . This allows you to also make rather large types Copy . Can implementing Copy be detrimental to performance if the size of the type is "large"? If Copy should always be implemented, why is it not an auto-trait like Sync and Send for those types which can

Compile error when trying to use increment operator

一笑奈何 提交于 2020-03-01 01:48:29
问题 During work on a side project I've tried to use an increment operator, as following: fn main() { let mut my_var = 5; my_var++; } and received the following error: error: expected expression, found `+` --> src\main.rs:3:12 | 3 | my_var++; | ^ What's wrong with my code? 回答1: Increment (++) and decrement (--) operators are not supported in Rust. From Rust's FAQ: Why doesn't Rust have increment and decrement operators? Preincrement and postincrement (and the decrement equivalents), while

Rust语言开发基础(三)开发工具攻略

百般思念 提交于 2020-03-01 01:15:17
一、Subline Text 3 1. 插件下载: Ctrl+Shift+P 调用命令面板,我们就会找到一些以“Package Control:”开头的命令,找到 Install Package (安装扩展),确定后出现命令行, 输入:Rust ,找到插件,确认安装 输入:RustAutoComplete,找到racer插件,确认安装 输入:RustCodeFormatter 格式化插件,顺便安装 Ctrl+Shift+P 调用命令面板,输入:Package Control: List Package,显示列出已安装的插件 2. 插件配置 编辑 Sublime 下的插件包管理下的 RustAutoComplete 下的 Settings - User ,写入 { // racer.exe绝对路径 "racer": "D:/RustPath/racer/target/debug/racer.exe", // rust源码文件路径 "search_paths": [ "D:/RustPath/source/rust-nightly-src/rust-nightly/src" ] } 其实文件就在:Sublime Text的Packages\User目录下(我机器是C:\Users\XXX\AppData\Roaming\Sublime Text 3\Packages\User) 二

Is it possible to unpack a tuple into function arguments?

无人久伴 提交于 2020-02-29 10:03:59
问题 If I want to unpack a tuple and pass it as arguments is there a way to do this: //Does not compile fn main() { let tuple = (10, Vec::new()); foo(tuple); } fn foo(a: i32, b: Vec<i32>) { //Does stuff. } Instead of having to do this: fn main() { let tuple = (10, Vec::new()); foo(tuple.0, tuple.1); } fn foo(a: i32, b: Vec<i32>) { //Does stuff. } 回答1: On a nightly compiler: #![feature(fn_traits)] fn main() { let tuple = (10, Vec::new()); std::ops::Fn::call(&foo, tuple); } fn foo(a: i32, b: Vec<i32

Java开发者薪资最低?程序员只能干到30岁?国外真的没有996?Intellij真的比Eclipse受欢迎?

余生长醉 提交于 2020-02-29 08:03:48
Stack Overflow作为全球最大的程序设计领域的问答网站,每年都会出据一份开发者调查报告。近日,Stack Overflow公布了其第9次年度开发者调查报告( https://insights.stackoverflow.com/survey/2019),这份报告基于对9万 Stack Overflow用户的调查。涉及众多领域,今天,挑其中和广大开发者最息息相关的几个重点调查结果给大家介绍一下。 这份报告的受访者主要是国外的开发者,其中的数据并不能完全的反应中国开发者的实际情况,但是也可以从一些侧面看出整个行业的一些信息。 这份报告还可以揭示几个一直困扰开发者的问题的答案,如: 1、哪种编程语言的开发者最赚钱? 2、Eclipse和Intellij哪个更受欢迎? 3、程序员可以干到多少岁? 4、哪种编程语言最受开发者欢迎? 5、国外程序员真的没有996吗? 6、到底要不要做Code Review? 接下来我们主要从技术、工作、开发者、薪水等4个方面展开,分析下这份报告。 一、关于技术 在Stack Overflow每年的报告中,都会对开发者所使用的技术做比较详尽的调查,其中包含编程语言、常用框架、甚至使用的操作系统等。 先来一张Stack Overflow描绘的技术全景图,方便开发者们了解自己所使用的技术所在的位置,以及和其他技术的关联性。 最常用的开发语言 在所有技术中

rust

让人想犯罪 __ 提交于 2020-02-29 04:57:03
books -------------- Rust 中文教程 RustPrimer http://wiki.jikexueyuan.com/project/rust-primer/any/any.html 中国人写的电子书 有入门知识,比如语法,ide,cargo,tarit,泛型,可变性,所有权,生命周期,模块,错误处理,macro,标准库,并发,test,etc trpl Rust 程序设计语言 https://kaisery.github.io/trpl-zh-cn 中文翻译 相当全面 A Guide to Porting C/C++ to Rust(英文) https://www.bookstack.cn/read/cpp-to-rust-book/ 针对c++程序员的rust入门书 比较了c++和rust的各项功能 Rust 编程语言 http://wiki.jikexueyuan.com/project/rust-1.7/ 里面有些高级内容比如unsafe,条件编译,内联汇编,etc 教程 https://special-csdncms.csdn.net/rust/index.shtml 内容很多链接已经失效,但可以google到 高级和不安全的Rust编程的黑暗艺术 https://doc.rust-lang.org/nomicon/README.html