Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Resolving conflicts w.r.t ambiguous names during imports in rust

New to rust and was trying to develop an application in rust, but ran into an issue.

In my application, i have to use zip module for unzipping a .zip file and need polars for analysis.

my imports looks like something below.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

use zip::ZipArchive;
use polars::prelude::*;

.
.

but unfortunately rust-analyzer is complaining with the following message.

unresolved import `zip::ZipArchive`
no `ZipArchive` in `chunked_array::ops::zip

I tried the following too with no luck.

use zip::ZipArchive;
use polars::prelude::*;
use polars::chunked_array::ops::{zip as chunked_zip};
.
.

In my code, i am not explicitly using chunked_array::ops::zip, but would like to understand how to solve in both cases.

  1. Do not explicitly use chunked_array::ops::zip
  2. explicitly use chunked_array::ops::zip

Any help would be much appreciated!!

>Solution :

That’s why glob imports are usually frowned upon, especially if the module you import from has popular names like zip.

You can either import from zip with an absolute path use ::zip::ZipArchive1,

explicitly import the things you need yourself and remove the use polars::prelude::*;

Or rename the zip crate for example in your Cargo.toml:

[dependencies]
zip_renamed = { package = "zip", … }

1) Thanks Sven Marnach

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading