Rust 程序设计语言 简体中文版 1.85.0
error 现在我们已经了解了变量如何工作,让我们看看变量可以拥有的更多数据类型。 42/562Rust 程序设计语言 简体中文版 数据类型 在 Rust 中,每一个值都有一个特定 数据类型(data type),这告诉 Rust 它被指定为何种数 据,以便明确数据处理方式。我们将看到两类数据类型子集:标量(scalar)和复合 (compound)。 记住,Rust 是 静态类型(statically some_string.push_str(", world"); | ^^^^^^^^^^^ `some_string` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: consider changing this to be a mutable reference 防止同一时间对同一数据存在多个可变引 用。新 Rustacean 们经常难以适应这一点,因为大部分语言中变量任何时候都是可变的。这 个限制的好处是 Rust 可以在编译时就避免数据竞争。数据竞争(data race)类似于竞态条 件,它可由这三个行为造成: • 两个或更多指针同时访问同一数据。 • 至少有一个指针被用来写入数据。 • 没有同步数据访问的机制。 数据竞争会导致未定义行为,难以在运行时追踪,并且难以诊断和修复;Rust0 码力 | 562 页 | 3.23 MB | 8 天前3Tornado 6.5 Documentation
linksCHAPTER TWO HELLO, WORLD Here is a simple “Hello, world” example web app for Tornado: import asyncio import tornado class MainHandler(tornado.web.RequestHandler): def get(self): self.write("Hello await or yield keywords. Examples Here is a sample synchronous function: from tornado.httpclient import HTTPClient def synchronous_fetch(url): http_client = HTTPClient() response = http_client.fetch(url) here is the same function rewritten asynchronously as a native coroutine: from tornado.httpclient import AsyncHTTPClient async def asynchronous_fetch(url): http_client = AsyncHTTPClient() response = await0 码力 | 272 页 | 1.12 MB | 2 月前3Tornado 6.5 Documentation
wiki/Links] Hello, world Here is a simple “Hello, world” example web app for Tornado: import asyncio import tornado class MainHandler(tornado.web.RequestHandler): def get(self): self await or yield keywords. Examples Here is a sample synchronous function: from tornado.httpclient import HTTPClient def synchronous_fetch(url): http_client = HTTPClient() response = http_client here is the same function rewritten asynchronously as a native coroutine: from tornado.httpclient import AsyncHTTPClient async def asynchronous_fetch(url): http_client = AsyncHTTPClient() response0 码力 | 437 页 | 405.14 KB | 2 月前3
共 3 条
- 1