【Rust深入浅出】翻译What Is Ownership

What Is Ownership?

Ownership is a set of rules that govern how a Rust program manages memory. All programs have to manage the way they use a computer’s memory while running. Some languages have garbage collection that regularly looks for no-longer-used memory as the program runs; in other languages, the programmer must explicitly allocate and free the memory. Rust uses a third approach: memory is managed through a system of ownership with a set of rules that the compiler checks. If any of the rules are violated, the program won’t compile. None of the features of ownership will slow down your program while it’s running.

Owership 是一套规则,他用来治理Rust怎样管理内存,所有的程序都有去管理内存的方法,他们使用计算机及的内存并运行,有一些语言拥有垃圾收集,在运行期间他们定期的查看没有长期使用的内存,有一些其他语言,开发者必须明确的分配可用的的内存,Rust使用了第三种方式;内训管理是通过系统的ownership,一套规则,在编译的时候检查,如果任何规则被违反,这个程序将不会被编译,没有功能会因为ownership减慢你的程序运行

Because ownership is a new concept for many programmers, it does take some time to get used to. The good news is that the more experienced you become with Rust and the rules of the ownership system, the easier you’ll find it to naturally develop code that is safe and efficient. Keep at it!

因为ownership对应开发者来说是一个新的概念,会用一些时间去适应它,ownership 的好消息是你会对rust的规则有更多经验,你将会找到简单的开发方式,是更安全而且高效的,坚持使用它!

When you understand ownership, you’ll have a solid foundation for understanding the features that make Rust unique. In this chapter, you’ll learn ownership by working through some examples that focus on a very common data structure: strings.

这时候你明白了ownership。你将会拥有坚实的基础去明白这个功能让Rust独一无二,在这一章中,你将会通过一些例子(非常常用的数据结构:string)学习到ownership怎样工作

你可能感兴趣的:(rust,开发语言,后端)