【发布时间】:2019-02-21 00:12:33
【问题描述】:
我在一个文件中有 2 个特征实现。如何从Trait 的第二个实现中调用first_function?
impl<T: Trait> Module<T> {
pub fn first_function() {
// some code here
}
}
impl<T: Trait> Second<T::SomeType> for Module<T> {
pub fn second_function() {
// Needs to call the first function available in first trait implementation.
}
}
【问题讨论】:
-
请查看如何创建minimal reproducible example,然后查看edit 您的问题以包含它。我们无法分辨代码中存在哪些类型、特征、字段等。尝试在Rust Playground 或全新的 Cargo 项目中重现您的错误。有Rust-specific MCVE tips 可以用来减少您在此处发布的原始代码。
-
来自
Trait的第二个实现 - 这里只有 一个Trait的实现。