Rust 程序设计语言 简体中文版 1.85.0hosting。但是 hosting 的内容 (contents)仍然是私有的;这表明使模块公有并不使其内容也是公有的。模块上的 pub 关键 字只允许其父模块引用它,而不允许访问内部代码。因为模块是一个容器,只是将模块变为公 有能做的其实并不太多;同时需要更深入地选择将一个或多个项变为公有。 示例 7-6 中的错误说,add_to_waitlist 函数是私有的。私有性规则不但应用于模块,还应用 于结构体、枚举、函数和方法。 crate 中 公有项列表之上,如图 14-2 所示: 图 14-2:包含 my_crate 整体描述的注释所渲染的文档 位于项之中的文档注释对于描述 crate 和模块特别有用。使用它们描述其容器整体的目的来帮 助 crate 用户理解你的代码组织。 304/562Rust 程序设计语言 简体中文版 使用 pub use 导出便捷的公有 API 公有 API 的结构是你发布 crate LimitTracker { messenger, value: 0, max, } } pub fn set_value(&mut self, value: usize) { self.value = value; let percentage_of_max = self0 码力 | 562 页 | 3.23 MB | 1 月前3
Tornado 6.5 DocumentationAsyncHTTPClient() my_future = Future() fetch_future = http_client.fetch(url) def on_fetch(f): my_future.set_result(f.result().body) fetch_future.add_done_callback(on_fetch) return my_future Notice that the that yields Queue.get pauses until there is an item in the queue. If the queue has a maximum size set, a coroutine that yields Queue.put pauses until there is room for another item. A Queue maintains url_seeker.urls async def main(): q = queues.Queue() start = time.time() fetching, fetched, dead = set(), set(), set() async def fetch_url(current_url): if current_url in fetching: return print("fetching %s"0 码力 | 272 页 | 1.12 MB | 3 月前3
Tornado 6.5 DocumentationAsyncHTTPClient() my_future = Future() fetch_future = http_client.fetch(url) def on_fetch(f):my_future.set_result(f.result().body) fetch_future.add_done_callback(on_fetch) return my_future Notice that yields Queue.get pauses until there is an item in the queue. If the queue has a maximum size set, a coroutine that yields Queue.put pauses until there is room for another item. A Queue maintains async def main(): q = queues.Queue() start = time.time() fetching, fetched, dead = set(), set(), set() async def fetch_url(current_url): if current_url in fetching: return0 码力 | 437 页 | 405.14 KB | 3 月前3
Julia 1.11.4Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 773 43.7 Set-Like Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 789 43.8 Dequeues mathematical use. More precisely, the set of all finite-length strings S together with the string concatenation operator * forms a free monoid (S, *). The identity element of this set is the empty string, "". Whenever (y, x) : (x, y) julia> gap((min, max)) = max - min julia> gap(minmax(10, 2)) 8 Notice the extra set of parentheses in the definition of gap. Without those, gap would be a two-argument function, and0 码力 | 2007 页 | 6.73 MB | 3 月前3
Julia 1.11.5 DocumentationDictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 773 43.7 Set-Like Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 789 43.8 Dequeues mathematical use. More precisely, the set of all finite-length strings S together with the string concatenation operator * forms a free monoid (S, *). The identity element of this set is the empty string, "". Whenever (y, x) : (x, y) julia> gap((min, max)) = max - min julia> gap(minmax(10, 2)) 8 Notice the extra set of parentheses in the definition of gap. Without those, gap would be a two-argument function, and0 码力 | 2007 页 | 6.73 MB | 3 月前3
Julia 1.11.6 Release NotesDictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 773 43.7 Set-Like Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 789 43.8 Dequeues mathematical use. More precisely, the set of all finite-length strings S together with the string concatenation operator * forms a free monoid (S, *). The identity element of this set is the empty string, "". Whenever (y, x) : (x, y) julia> gap((min, max)) = max - min julia> gap(minmax(10, 2)) 8 Notice the extra set of parentheses in the definition of gap. Without those, gap would be a two-argument function, and0 码力 | 2007 页 | 6.73 MB | 3 月前3
julia 1.13.0 DEVDictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 808 44.7 Set-Like Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 824 44.8 Dequeues mathematical use. More precisely, the set of all finite-length strings S together with the string concatenation operator * forms a free monoid (S, *). The identity element of this set is the empty string, "". Whenever = max - min gap (generic function with 1 method) julia> gap(minmax(10, 2)) 8 Notice the extra set of parentheses in the definition of gap. Without those, gap would be a two-argument function, and0 码力 | 2058 页 | 7.45 MB | 3 月前3
Julia 1.12.0 RC1Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 806 44.7 Set-Like Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 822 44.8 Dequeues mathematical use. More precisely, the set of all finite-length strings S together with the string concatenation operator * forms a free monoid (S, *). The identity element of this set is the empty string, "". Whenever (y, x) : (x, y) julia> gap((min, max)) = max - min julia> gap(minmax(10, 2)) 8 Notice the extra set of parentheses in the definition of gap. Without those, gap would be a two-argument function, and0 码力 | 2057 页 | 7.44 MB | 3 月前3
Julia 1.12.0 Beta4Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 805 44.7 Set-Like Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 821 44.8 Dequeues mathematical use. More precisely, the set of all finite-length strings S together with the string concatenation operator * forms a free monoid (S, *). The identity element of this set is the empty string, "". Whenever (y, x) : (x, y) julia> gap((min, max)) = max - min julia> gap(minmax(10, 2)) 8 Notice the extra set of parentheses in the definition of gap. Without those, gap would be a two-argument function, and0 码力 | 2057 页 | 7.44 MB | 3 月前3
Julia 1.12.0 Beta3Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 805 44.7 Set-Like Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 821 44.8 Dequeues mathematical use. More precisely, the set of all finite-length strings S together with the string concatenation operator * forms a free monoid (S, *). The identity element of this set is the empty string, "". Whenever (y, x) : (x, y) julia> gap((min, max)) = max - min julia> gap(minmax(10, 2)) 8 Notice the extra set of parentheses in the definition of gap. Without those, gap would be a two-argument function, and0 码力 | 2057 页 | 7.44 MB | 3 月前3
共 21 条
- 1
- 2
- 3













