腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
搜索
关闭
文章
问答
(9999+)
视频
开发者手册
清单
用户
专栏
沙龙
全部问答
原创问答
Stack Exchange问答
更多筛选
回答情况:
全部
有回答
回答已采纳
提问时间:
不限
一周内
一月内
三月内
一年内
问题标签:
未找到与 相关的标签
筛选
重置
1
回答
为什么&'a Box<
Trait
>被当作&'a Box<
Trait
+ 'static>而不是‘a Box<
Trait
+ 'a>?
鉴于这一守则:struct Child;struct Father<'a> {} let child: Box<dyn
Trait
> = B
浏览 0
修改于2018-10-29
得票数 4
回答已采纳
2
回答
<T:
Trait
> Box<T>和&
Trait
/ Box<
Trait
>之间的区别是什么?
在编写带有特征的代码时,您可以将该特性放在一个特征绑定中: println!("{:?}", v); println!("{:?}", v); myfunction1(Box::new(5));} 或直接在Box或引用类型中
浏览 7
修改于2017-10-30
得票数 13
回答已采纳
1
回答
将Option<impl
Trait
>转换为Option<Box<dyn
Trait
>>
是否可以将Option<impl
Trait
>映射到Option<Box<dyn
Trait
>>?
trait
TestTrait {} item: Option<Box<dyn TestTrait
浏览 8
修改于2021-01-07
得票数 3
回答已采纳
1
回答
从
Trait
1 Box<dyn
Trait
1 +
Trait
2>返回和恢复
如果我有一个Box<dyn
Trait
1 +
Trait
2>,我可以返回一个&dyn
Trait
1吗?
trait
Node {} fn get_node(&self, key: &str) -
浏览 5
修改于2020-02-11
得票数 2
回答已采纳
3
回答
Trait
::<T>和<
Trait
<T>>有什么区别?
我有一个类型,它的方法可以通过但我不明白这和在C++中,我希望这样做:这两个不一样吗?他们两人似乎都把<T>专门化称为method on SomeTrait。
浏览 2
修改于2019-12-02
得票数 5
回答已采纳
1
回答
如何将Box<dyn
Trait
>转换为Rc<dyn
Trait
>?
我有一个接收Box的函数,需要将其转换为Rc以共享线程内的只读所有权。 使用一些T: Sized的Box,我们可以做Rc::new(*my_box),但不幸的是,这不适用于大小不大的特征对象。 这里有一个过于简单的例子,希望能澄清这个问题: 游乐场链接 我在这里和那里看到了一些关于公开内部RcBox以支持在Box和Rc之间移动的东西,但是AFAIK它现在不能使用。 有没有解决这个问题的办法? 或者,如果这种类型的转换是不可能的,那么存储特征对象的推荐方法是什么,该特征对象可以变异到某个点,然后在该点之后与程序的其余部分不变地共享? 当我知道到目前为止我只有一个所有者时,使用Rc>似乎有
浏览 40
提问于2021-02-28
得票数 1
回答已采纳
1
回答
`<T:
Trait
>`和‘`where :
Trait
`’之间有什么区别?
在的Send特性中,我看到了两者where和这两种语法之间有什么区别,如果我为自己的特性编写impl声明,它将如何影响我的代码?
浏览 0
修改于2019-11-23
得票数 14
回答已采纳
4
回答
为`
trait
`定义` `copy` `
给定: sealed
trait
X { val x: String }case class B(x: String) extends
浏览 18
提问于2016-08-23
得票数 2
回答已采纳
1
回答
Rust Into-
Trait
on Options
Option<D> name: Option<String> spec: Option<C>现在,我想将A上的Into-
trait
fn into(self) -> B { spec: self.spec.into() }但铁锈不允许这样做: | 615 | spec: self.spec
浏览 18
提问于2021-06-11
得票数 0
回答已采纳
1
回答
`
trait
`的依赖注入
给定以下FooService | def go: Int defined
trait
FooService | def f = go + 42defined
trait
MainService
浏览 3
提问于2015-07-04
得票数 3
2
回答
Rc<
Trait
>到Option<T>?
我正在尝试实现如下方法: Rc::try_unwrap(rc).ok().and_then(|
trait
_object
浏览 6
修改于2017-01-12
得票数 2
回答已采纳
1
回答
在“模板”和函数声明之间使用: template<typename
trait
> Using tr = base_
trait
<
trait
> void fn(tr::type arg) { ... }
template<typename
trait
> template<typename
trait
> using thetype = typename
trait
::*/
浏览 0
修改于2018-09-26
得票数 0
2
回答
如何克隆Vec<Box<dyn
Trait
>>?
trait
Foo {} x: i32, fn value
浏览 1
修改于2021-11-10
得票数 5
回答已采纳
2
回答
通过信道发送Vec<Box<
Trait
>>
我正试图通过一个频道发送Vec<Box<
Trait
>>。我想,发送部分起作用了。在对recv()进行Vec之后,我尝试对其进行迭代,并将内部值的引用传递给一个函数,如果出现错误,该函数将失败: --> src/main.rs:12:1312 | K::abc(&something); | ^^^^^^ the
trait
浏览 1
修改于2018-06-12
得票数 4
回答已采纳
1
回答
"natural_alignment_of“type_
trait
?
类似于以下将编译的概念性natural_alignment_of type_
trait
: size_t natural_char_alignment = natural_alignment_of< Maximally_Aligned_Char
浏览 1
修改于2013-12-06
得票数 0
2
回答
如何将Vec<Box<dyn
Trait
>>移动到Vec<Rc<RefCell<dyn
Trait
>>>中
我有一个Vec<Box<dyn
Trait
>>作为输入,我想在Vec<Rc<RefCell<dyn
Trait
>>>中存储它的元素。做这件事最好的方法是什么?我尝试过:use std::rc::Rc; let mut source: Vec<Box<dyn
Trait
>> = Vec::new();
浏览 0
提问于2020-05-24
得票数 5
1
回答
返回对Box<dyn
Trait
>的引用
我有几个结构实现了一个特性:impl Dog for Animal{} impl Cat for Animal
浏览 1
提问于2020-04-18
得票数 3
回答已采纳
2
回答
将Rc<ConcreteType>转换为Rc<
Trait
>
我做了这个: let
浏览 1
修改于2018-11-13
得票数 3
回答已采纳
1
回答
如何利用制造技术实现:with_
trait
我正在考虑将许多模拟程序从FactoryGirl迁移到制作gem。是否有一种普遍接受的方法来做这与制造?
浏览 5
提问于2015-04-05
得票数 6
1
回答
Scala:从mixin类型别名继承时发现“类类型必需但{
trait
}具有{
trait
}”
我定义了一个非常常见的类型别名:}import java.security.Key}[ERROR] /home/peng/git/datapassport/core/src/main/scala/com/s
浏览 2
提问于2015-03-16
得票数 2
回答已采纳
第 2 页
第 3 页
第 4 页
第 5 页
第 6 页
第 7 页
第 8 页
第 9 页
第 10 页
第 11 页
点击加载更多
领券