rust

rust 播放音乐

六眼飞鱼酱① 提交于 2020-05-03 20:14:47
extern crate rodio; use std::io::BufReader; fn main() { let device = rodio::default_output_device().unwrap(); let sink = rodio::Sink::new(&device); let file = std::fs::File::open("D:\\dev\\test\\xrust\\src\\1.wav").unwrap(); let decoder = rodio::Decoder::new(BufReader::new(file)).unwrap(); sink.append(decoder); sink.sleep_until_end(); } 来源: oschina 链接: https://my.oschina.net/zhupengdaniu/blog/4263521

Do I need to Box child structs of a Boxed struct to get everything on the heap?

瘦欲@ 提交于 2020-04-30 15:44:15
问题 I don't understand in Rust what is happening with a struct in a struct when we Box the parent struct. struct Outer1 { child: Inner1, } struct Inner1 { n: i32, } struct Outer2 { child: Box<Inner2>, } struct Inner2 { n: Box<i32>, } pub fn main() { let x1 = Box::new(Outer1 { child: Inner1 { n: 1 }, }); let x2 = Box::new(Outer2 { child: Box::new(Inner2 { n: Box::new(1) }), }); } x2.child and x2.child.n should be on the heap, right? Where is x1.child and x1.child.n : the stack or the heap? If

Replacing a trait bound with a trait alias says “the size for values cannot be known at compilation time” [duplicate]

烈酒焚心 提交于 2020-04-30 11:47:50
问题 This question already has an answer here : Sized is not implemented for the type Fn (1 answer) Closed 4 months ago . After reading about trait aliases, I tried to switch this code: pub fn authorize<LoadClient>(get_client: LoadClient) -> Result<String, ()> where LoadClient: FnOnce(String) -> Result<Client, LoadingError>, { unimplemented!() } to #![feature(trait_alias)] trait LoadClient = FnOnce(String) -> Result<Client, ClientLoadingError>; pub fn authorize(get_client: LoadClient) -> Result

Replacing a trait bound with a trait alias says “the size for values cannot be known at compilation time” [duplicate]

a 夏天 提交于 2020-04-30 11:46:23
问题 This question already has an answer here : Sized is not implemented for the type Fn (1 answer) Closed 4 months ago . After reading about trait aliases, I tried to switch this code: pub fn authorize<LoadClient>(get_client: LoadClient) -> Result<String, ()> where LoadClient: FnOnce(String) -> Result<Client, LoadingError>, { unimplemented!() } to #![feature(trait_alias)] trait LoadClient = FnOnce(String) -> Result<Client, ClientLoadingError>; pub fn authorize(get_client: LoadClient) -> Result

Replacing a trait bound with a trait alias says “the size for values cannot be known at compilation time” [duplicate]

ぃ、小莉子 提交于 2020-04-30 11:46:00
问题 This question already has an answer here : Sized is not implemented for the type Fn (1 answer) Closed 4 months ago . After reading about trait aliases, I tried to switch this code: pub fn authorize<LoadClient>(get_client: LoadClient) -> Result<String, ()> where LoadClient: FnOnce(String) -> Result<Client, LoadingError>, { unimplemented!() } to #![feature(trait_alias)] trait LoadClient = FnOnce(String) -> Result<Client, ClientLoadingError>; pub fn authorize(get_client: LoadClient) -> Result

vlang module 使用

六月ゝ 毕业季﹏ 提交于 2020-04-30 03:09:37
vlang 支持module,概念以及使用类似rust 以及golang 的gopath(从当前的文档以及使用来说),但是还不完整 以及是够用,但是有问题 v module 试用 项目结构 ├── modmain. v // main 入口 └── v ├── CHANGELOG. md ├── CONDUCT. md ├── CodeStructure. md ├── LICENSE ├── README. md ├── azure - pipelines. yml ├── base64 ├── builtin ├── compiler ├── examples ├── fetchbaidu // 我们开发的module ├── gg ├── gl ├── glfw ├── glm ├── gx ├── http ├── json ├── log ├── math ├── os ├── rand ├── stbi ├── sync ├── termcolor ├── tests ├── thirdparty └── time 模块代码 v/fetchbaidu/fetchbaidu.v module fetchbaidu import http // pub 暴露方法类似rust pub fn fetchindexpage() { resp : = http. get(

通过9个Linux-0.11实验学习操作系统

微笑、不失礼 提交于 2020-04-28 03:28:28
<font size="3"> ## 简介 2019年秋,我自学了一下哈工大的操作系统课程,感觉其设计的教程和实验作为操作系统入门是个不错的选择(虽然是基于较老的Linux-0.11写的)。实验大致覆盖了操作系统中的核心概念,例如启动、中断、外设IO、上下文切换/系统调用,进程管理与调度,进程间通信,内存管理/地址转换,文件系统等。而且每个实验在教材中都有对应的说明,做起来很顺畅。我做完后整理了一下相关资源,希望能帮到一些自学的同学。 <br /> 指导教材 该课程使用的教材是 李治军 和 刘宏伟 编著的《操作系统原理、实现与实践》(ISBN: 978-7-04-049245-3),你可以在 这里 获得。除了和课程对应的实验,这本书还在最后设计了4个大的项目,包含内核级线程,虚拟内存,GUI以及网络协议的实现。 另外,赵炯 编著的《Linux内核完全注释-内核版本0.11》也是一本不错的参考书,你可以在 这里 获取。 <br /> 实验资源 你可以在 Hack-Linux-0.11 上获得开发环境需要的工具,以及每个实验的参考代码、示例效果和注意事项。该仓库的布局说明如下: oslab.zip:原Linux 0.11的代码和在GNU/Linux下开发所需的工具,例如Bochs 2.3.7和GCC 3.4。 tmp/: 一些杂项,和主体实验没什么关系。 Lab 6.Ext.

unity 3d开发的大型网络游戏

限于喜欢 提交于 2020-04-27 18:51:13
unity 3d开发的大型网络游戏 一、总结 1、unity的 官网 上面应该有游戏列表 2、 unity3D是很好的3d游戏引擎,也支持2d,也能做很多画面精良的3A级游戏 3、 范围 :电脑游戏,手机游戏,网页游戏 3、 案例 :unity3d开发的 网页游戏 有坦克英雄、新仙剑Online、蒸汽之城、绝代双骄等, 手机游戏 有 炉石传 说、 神庙逃亡 、武士2、神庙逃亡2...... 二、哪些游戏是用unity3d做的? unity3D是如今绝大多数游戏开发团队的首选3D引擎,并且它在2D上的表现也及为优秀。它可以轻松解决很多其它引擎不能解决的问题,哪些游戏是用unity3d做的?小编特意帮大家问了: 有的网友说unity3d开发的游戏,多数都是用在iphone以及android等手机端游戏。 比较出名的是 武士系列游戏,涂鸦保龄球,城堡勇士,3D方块贴图,以及很多僵尸游戏。 还有网友说:unity3d开发的 网页游戏 有坦克英雄、新仙剑Online、蒸汽之城、绝代双骄等, 手机游戏 有炉石传说、神庙逃亡、武士2、神庙逃亡2...... 具体来了解下unity3d吧: Unity的游戏和应用可以用C#语言,UnityScript(一种JavaScript的扩展)或者Boo(一种受Python启发的语言)来开发,其编译过程根据不同的目标平台而变化。 在PC

Rust 能够取代 C 语言吗?

假装没事ソ 提交于 2020-04-26 09:18:12
https://www.infoq.cn/article/Dmp1BvCyVrVRorOkreXj Rust 是 Mozilla 基金会的一个雄心勃勃的项目,号称是 C 语言和 C++ 的继任者。一直以来,C/C++ 中的一些基本问题都没能得到解决,比如分段错误、手动内存管理、内存泄漏风险和不可预测的编译器行为。Rust 的诞生就是为了解决这些问题,并提高安全性和性能。 Evrone(一家软件公司)在很多项目中使用了 Rust,我们的工程师们这方面在积累了丰富的经验。在这篇文章中,我们将分享 Rust 的一些主要特性。 主要特性 强静态类型; 无垃圾回收以及通过指针手动控制数据存储位置的能力; 强大的内置静态代码分析器,有助于避免与内存管理和多线程相关的问题; C 语言风格的语法,具有简短的关键字。 Rust 简史 Graydon Hore 于 2008 年发起 Rust 项目。2009 年,Mozilla 表达了对这个项目的兴趣。一年之后,项目正式公开。2012 年,Rust 的第一个 alpha 版本发布。一年后,Servo Web 引擎(基于 Rust)开发人员宣布,他们得到了三星公司的支持,将引擎移植到 ARM 架构。 Rust 1.0 于 2015 年 5 月发布。同年,Rust 在 Stack Overflow 发布的最受欢迎开发工具排行榜中排名第三。从 2016