Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unresolved imports vtkio::export_ascii, vtkio::import #32

Closed
hunter1992 opened this issue Jun 7, 2023 · 1 comment
Closed

unresolved imports vtkio::export_ascii, vtkio::import #32

hunter1992 opened this issue Jun 7, 2023 · 1 comment

Comments

@hunter1992
Copy link

When I tested the import/export example, the following error occurred:

error[E0432]: unresolved imports `vtkio::export_ascii`, `vtkio::import`
 --> src/main.rs:2:13
  |
2 | use vtkio::{export_ascii, import};
  |             ^^^^^^^^^^^^  ^^^^^^ no `import` in the root
  |             |
  |             no `export_ascii` in the root

I want to ask how to solve this problem?

@elrnv elrnv closed this as completed in 83d7d2a Jun 8, 2023
@elrnv
Copy link
Owner

elrnv commented Jun 8, 2023

Thank you for flagging this! The example in the readme is slightly outdated. I just pushed a commit fixing it. The correct usage is found on docs.rs. In general, for Rust libraries, docs.rs is a better source for finding examples because they are often at least compiled with the corresponding revision of the code.

With the current API, the example should be:

use vtkio::model::*; // import model definition of a VTK file
fn main() {
    use std::path::PathBuf;
    let file_path = PathBuf::from("assets/tet.vtk");

    let mut vtk_file = Vtk::import(&file_path)
        .expect(&format!("Failed to load file: {:?}", file_path));

    vtk_file.version = Version::new((4,2)); // arbitrary change

    vtk_file.export_ascii(&file_path)
        .expect(&format!("Failed to save file: {:?}", file_path));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants