在
问题在于语句
我阅读了文档,文档中说
src/lib.rs
文件中,我有以下内容。extern crate opal_core;
mod functions;
mod context;
mod shader;
然后在src/context.rs
中,我有类似这样的内容,试图从src/shader.rs
导入符号:
use opal_core::shader::Stage;
use opal_core::shader::Shader as ShaderTrait;
use opal_core::GraphicsContext as GraphicsContextTrait;
use functions::*; // this import works fine
use shader::*; // this one doesn't
pub struct GraphicsContext {
functions: Gl
}
fn shader_stage_to_int(stage: &Stage) -> u32 {
match stage {
&Stage::Vertex => VERTEX_SHADER,
&Stage::Geometry => GEOMETRY_SHADER,
&Stage::Fragment => FRAGMENT_SHADER,
}
}
impl GraphicsContextTrait for GraphicsContext {
/// Creates a shader object
fn create_shader(&self, stage: Stage, source: &str) -> Box<ShaderTrait> {
let id;
unsafe {
id = self.functions.CreateShader(shader_stage_to_int(&stage));
}
let shader = Shader {
id: id,
stage: stage,
context: self
};
Box::new(shader)
}
}
问题在于语句
use shader::*;
报错,显示为unresolved import。我阅读了文档,文档中说
use
语句总是从当前crate的根目录(opal_driver_gl
)开始,所以我认为shader::*
应该导入opal_driver_gl::shader::*
,但实际上并没有这样做。我需要在这里使用self
或super
关键字吗?
shader
中是否包含来自context
的任何导入?全局导入可能会导致模块递归依赖于自身而出现问题。尝试移除*
并列出您实际使用的所有符号。 - DK.