Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/daheige/rust-bible
/ functions
Functions
416 in github.com/daheige/rust-bible
⨍
Functions
416
◇
Types & classes
143
↓ 18 callers
Method
clone
(&self)
part7/grpc/grpc-demo/src/rust_grpc/hello.rs:217
↓ 17 callers
Function
open
(f: &mut File)
part1/compound_type/src/main.rs:244
↓ 10 callers
Method
write
(&self, content: String)
part6/inject-demo/src/main.rs:16
↓ 8 callers
Method
next
(&mut self)
part1/iterators/src/main.rs:69
↓ 7 callers
Method
append
(&self, data: T)
part1/link_demo/src/main.rs:23
↓ 4 callers
Method
get_unknown_fields
(&self)
part7/grpc/grpc-hello/src/rust_grpc/hello.rs:146
↓ 3 callers
Method
as_ref
(&self)
part7/grpc/grpc-hello/src/rust_grpc/hello.rs:215
↓ 3 callers
Method
clear
(&mut self)
part7/grpc/grpc-hello/src/rust_grpc/hello.rs:201
↓ 3 callers
Method
clone
(&self)
part7/grpc/grpc-demo/src/rust_grpc/app.grpc.hello.rs:218
↓ 3 callers
Method
display
覆盖默认实现
part1/generics_trait_lifetime/src/main.rs:96
↓ 3 callers
Method
eat
(&self)
part1/trait_bound/src/intro.rs:79
↓ 3 callers
Method
into_response
(self)
part5/axum-demo/src/main.rs:210
↓ 3 callers
Function
say
(name: &str)
part1/my-mod/src/main.rs:35
↓ 3 callers
Method
show
(&self)
part1/struct_demo/src/main.rs:39
↓ 3 callers
Method
sum
(&self)
part1/cell_demo/src/main.rs:41
↓ 2 callers
Function
async_action_exec
Rust异步编程,通过join执行Future
part1/async_await/src/main.rs:56
↓ 2 callers
Method
cmp
(&self, obj: &Self)
part1/generics_trait_lifetime/src/main.rs:196
↓ 2 callers
Method
cmp_display
where约定trait
part1/generics_trait_lifetime/src/main.rs:24
↓ 2 callers
Function
dance
()
part1/async_await/src/main.rs:43
↓ 2 callers
Method
fetch_cmd_res
(&mut self, name: String)
part3/redis-demo/src/main.rs:94
↓ 2 callers
Function
file_descriptor_proto
()
part7/grpc/grpc-hello/src/rust_grpc/hello.rs:436
↓ 2 callers
Function
give_me
(value: T)
part1/generics_demo/src/main.rs:1
↓ 2 callers
Function
handle_connection
访问地址:http://localhost:8080/ 异步的方式处理每个请求 由于 handle_connection 实现了 Send 特征,并且不会阻塞,因此它使用async-std spawn 多线程并行的处理请求是可行的 这里要提到的一点: async-std包允许我们使用多个线程的方式
part4/tcp-http-demo/src/main.rs:50
↓ 2 callers
Method
incr
(&self)
part4/async-tokio-demo/src/main.rs:21
↓ 2 callers
Method
init
(&self)
part1/trait_bound/src/intro.rs:29
↓ 2 callers
Function
learn_song
()
part1/async_await/src/main.rs:32
↓ 2 callers
Method
load
实现load方法,它是一个泛型方法 entity 上面必须实现init方法才可以调用 这里通过特征trait来约束参数类型T,必须是一个trait “:Loadable”部分表明了我们指定特征范围的方式。特征区间允许我们限制 泛型 API 可以接收的参数范围。指定泛型元素上的绑定的特征类似于我们为
part1/trait_bound/src/intro.rs:17
↓ 2 callers
Method
mut_unknown_fields
(&mut self)
part7/grpc/grpc-hello/src/rust_grpc/hello.rs:150
↓ 2 callers
Method
play
(&self)
part1/super_player/src/main.rs:44
↓ 2 callers
Function
say_hello
对刚接触 Rust 的程序员来说,辨别&str 和 String 的应用场景会存在一些困惑。最佳的 做法是尽可能使用带有&str 类型的 API,因为当字符串已经分配到某处时,只需引用该字 符串就可以节省复制和分配的成本。在程序中传递&str 几乎是零成本的:它几乎不会产生 分配成本,也不会复制内存
part1/advanced_concept/src/main.rs:213
↓ 2 callers
Method
say_hello
( &mut self, request: impl tonic::IntoRequest<super::HelloReq>, )
part7/grpc/grpc-demo/src/rust_grpc/hello.rs:84
↓ 2 callers
Function
sing_song
(song: Song)
part1/async_await/src/main.rs:38
↓ 2 callers
Function
spawn_and_log_error
(fut: F)
part4/a-chat/src/server.rs:184
↓ 1 callers
Function
accept_loop
(addr: impl ToSocketAddrs)
part4/a-chat/src/server.rs:26
↓ 1 callers
Function
add
泛型函数的参数类型上面绑定某种trait 由于函数返回了T,但是这个属于输出类型,所以继续在T上绑定了输出Add<Output = T>
part1/trait_bound/src/intro.rs:42
↓ 1 callers
Function
add2
(x:i32,y:i32)
part1/unit_test/src/main.rs:9
↓ 1 callers
Method
animate
这里trait可默认实现方法
part1/trait_bound/src/intro.rs:115
↓ 1 callers
Method
announce
(&self, announce: &str)
part1/generics_trait_lifetime/src/main.rs:386
↓ 1 callers
Function
another_fn
无返回值的函数定义
part1/variables/src/main.rs:100
↓ 1 callers
Function
broker_loop
(mut events: Receiver<Event>)
part4/a-chat/src/server.rs:129
↓ 1 callers
Function
build_user
(name: String, active: bool, sign_in_count: i64)
part1/compound_type/src/main.rs:15
↓ 1 callers
Function
calculate_cost
引用解构
part1/advanced_concept/src/main.rs:69
↓ 1 callers
Function
calculate_len
s 是一个不可变引用
part1/ref_var/src/main.rs:72
↓ 1 callers
Function
call
调用c提供的foo函数
part8/cc-demo/src/main.rs:22
↓ 1 callers
Function
change
创建可变引用通过 &mut方式创建
part1/owner_ship/src/main.rs:84
↓ 1 callers
Function
change
(s: &mut String)
part1/ref_var/src/main.rs:46
↓ 1 callers
Method
change_height
通过可变引用改变实例对象的值
part1/struct_demo/src/main.rs:35
↓ 1 callers
Function
close
(f: &mut File)
part1/compound_type/src/main.rs:248
↓ 1 callers
Method
code
(&self)
part1/trait_bound/src/intro.rs:101
↓ 1 callers
Function
configure_logger
(t: T)
part1/memory/lifetime/src/main.rs:99
↓ 1 callers
Method
connect
Attempt to create a new client by connecting to a given endpoint.
part7/grpc/grpc-demo/src/rust_grpc/hello.rs:30
↓ 1 callers
Function
connection_loop
(mut broker: Sender<Event>, stream: TcpStream)
part4/a-chat/src/server.rs:49
↓ 1 callers
Function
connection_writer_loop
( messages: &mut Receiver<String>, stream: Arc<TcpStream>, mut shutdown: Receiver<Void>, )
part4/a-chat/src/server.rs:94
↓ 1 callers
Function
consumer_message
(group: &str, topic: &str, brokers: Vec<String>)
part3/kafka-consumer/src/main.rs:22
↓ 1 callers
Function
count
()
part4/async-future-demo/src/main.rs:66
↓ 1 callers
Function
create_app
()
part7/web/rs-api/src/router/mod.rs:8
↓ 1 callers
Function
create_person
当特征作为返回值,同一个函数中所有可能的返回值类型必须是同一个类型实现的trait才可以
part1/generics_trait_lifetime/src/main.rs:247
↓ 1 callers
Function
dance
()
part4/async-future-demo/src/main.rs:23
↓ 1 callers
Function
display_me
将 impl trait作为参数,这种仅仅是实现了Display才可以传递给参数 通常建议将特征区间的 impl 特征语法用做函数的返回类型,比如说下面的lazy_add函数。 在参数位置使用它意味着我们不能使用 turbofish 运算符。 如果某些相关代码使用 turbofish 运算符来调用软
part1/trait_object/src/main.rs:43
↓ 1 callers
Function
display_me
===特征区间与 impl 特征语法=== impl 特征语法 直接使用了 impl Display,而不是指定 T:Display。这是 impl 特征语法 这为我们返回复杂或不方便表示的类型(例如函数的闭包)提供了便利。如果没有这种语法,则 必须使用 Box 智能指针类型将其放在指针后面返回,这
part1/trait_bound/src/intro.rs:139
↓ 1 callers
Function
do_more_tasks
返回返回一个执行器
part4/async-future-demo/src/main.rs:34
↓ 1 callers
Method
do_reader
(&self)
part1/memory/lifetime/src/main.rs:83
↓ 1 callers
Method
do_some_cmd
通过redis cmd模式调用相关的method
part3/redis-demo/src/main.rs:114
↓ 1 callers
Function
do_task
async fn 返回一个Future ,需要在执行的时候才能起到作用
part4/async-future-demo/src/main.rs:11
↓ 1 callers
Function
eat
泛型函数的参数是一个trait类型 下面的泛型函数的参数类型T通过where语句来实现trait绑定
part1/trait_bound/src/intro.rs:86
↓ 1 callers
Function
factory
函数调用后闭包获得了被释放的内存环境 通过 Box 装箱返回Fn,我们提供了一个已知大小的返回值,并允许它离开我们 的栈帧
part1/closures/src/main.rs:96
↓ 1 callers
Method
fetch_an_integer
% redis-cli 127.0.0.1:6379> get my_number "12" */
part3/redis-demo/src/main.rs:86
↓ 1 callers
Function
foo
(x: i64)
part1/error_handler/src/main.rs:149
↓ 1 callers
Function
generate_workout
(intensity: u32, random_number: u32)
part1/closures/src/main.rs:101
↓ 1 callers
Function
generate_workout2
(intensity: u32, random_number: u32)
part1/closures/src/main.rs:123
↓ 1 callers
Function
get_name
()
part4/time-future/src/main.rs:11
↓ 1 callers
Function
get_nth
items是一个usize类型的vec切片
part1/map_option_result/src/main.rs:2
↓ 1 callers
Function
get_one
省略生命周期标注
part1/memory/lifetime/src/main.rs:12
↓ 1 callers
Function
get_value
(s: &Vec<&str>)
part1/result_demo/src/main.rs:50
↓ 1 callers
Function
greet
定义greet函数
part8/cc-demo/src/foo.c:26
↓ 1 callers
Function
greet_world
()
part1/hello_world/src/main.rs:7
↓ 1 callers
Function
hello
定义hello函数
part8/cc-demo/src/foo.c:21
↓ 1 callers
Function
hello
异步函数返回的是一个future 等待某个时候被执行
part1/async_await/src/main.rs:26
↓ 1 callers
Function
hello_cat
()
part4/futures-demo/src/main.rs:8
↓ 1 callers
Function
hello_world
async fn 返回一个future 需要在一个执行者上面才可以运行
part4/futures-demo/src/main.rs:4
↓ 1 callers
Function
incr_task
(i: &Increment)
part4/async-tokio-demo/src/main.rs:27
↓ 1 callers
Function
increment_item
可变引用的解构
part1/advanced_concept/src/main.rs:63
↓ 1 callers
Function
interop_sort
实现函数interop_sort
part8/cc-cpp-demo/src/foo.cpp:13
↓ 1 callers
Function
lazy_add
函数返回一个trait
part1/trait_object/src/main.rs:48
↓ 1 callers
Function
lazy_adder
这里返回值是一个impl trait类型
part1/trait_bound/src/intro.rs:144
↓ 1 callers
Function
learn_and_sing
()
part4/async-future-demo/src/main.rs:27
↓ 1 callers
Function
learn_and_sing
.await是在代码块中按顺序执行,会阻塞后面的代码,但是此时会让出线程; block_on会阻塞直到Future执行完成。
part1/async_await/src/main.rs:50
↓ 1 callers
Function
learn_song
()
part4/async-future-demo/src/main.rs:15
↓ 1 callers
Method
log
(&self, content: &str)
part6/shaku-inject-demo/src/main.rs:21
↓ 1 callers
Method
log_date
(&self)
part6/shaku-inject-demo/src/main.rs:38
↓ 1 callers
Function
longest
生命周期注解的作用就是将多个引用的生命周期联系起来,方便借用检查器能确定引用的具体生命周期,也就是作用域的范围大小 生命周期参数名称通过'a 这种语法来标记,告诉rust多个引用的泛型生命周期参数如何相互联系 生命周期参数注解位于引用的&之后,并有一个空格来将引用类型与生命周期注解分割开 &i32
part1/generics_trait_lifetime/src/main.rs:362
↓ 1 callers
Function
longest_with_announce
结合泛型类型参数,trait bounds 和生命周期 ann是一个泛型参数T,它需要实现Display trait 特征,通过where来实现泛型特征的绑定 由于生命周期'a也是泛型,所以和T都同时放在尖括号中,用来定义参数的作用域范围
part1/generics_trait_lifetime/src/main.rs:403
↓ 1 callers
Function
makes_copy
i是i32属于标准的copy类型,将i传递给函数后,原来的变量依旧可以继续使用
part1/owner_ship/src/main.rs:64
↓ 1 callers
Function
message_publish
send message
part3/kafka-demo/src/main.rs:37
↓ 1 callers
Method
mixup
混入类型,泛型结构体中的方法也是可以支持泛型函数的
part1/generics_trait_lifetime/src/main.rs:56
↓ 1 callers
Function
new_summary
通过Box + dyn trait方式返回不同实现的trait dyn trait本质上一个指向具体类型实现的指针
part1/generics_trait_lifetime/src/main.rs:150
↓ 1 callers
Function
notify
trait bounds 表示trait 约束 参数是T 它是一个Summarizable trait 就可以调用summary方法
part1/generics_trait_lifetime/src/main.rs:136
↓ 1 callers
Method
output
(&self)
part1/generics_trait_lifetime/src/main.rs:241
↓ 1 callers
Method
output
(&self)
part1/generics_demo/src/main.rs:19
↓ 1 callers
Function
output_content
使用特征作为函数参数 实现了Summary特征 的 item 参数,是具体某个类型的借用 当某个类型实现了Summary trait,参数就可以传递&xxx模式作为参数传人到函数中
part1/trait_demo/src/main.rs:102
next →
1–100 of 416, ranked by callers