#Modules and "... is never used"

21 messages · Page 1 of 1 (latest)

wild flax
#

Hello, so I've finished most of the book (~ Chapter 19) and wanted to move on to a project.
Got recommended this project: https://picklenerd.github.io/pngme_book/
Now, I made the file structure in lib.rs:

pub mod args;
pub mod chunk;
pub mod chunk_type;
pub mod commands;
pub mod png;

Currently, in chunk_type.rs I have this:

pub enum ChunkType {
    Encrypted,
    RawMessage,
}

impl ChunkType {
    pub fn as_str(&self) -> &'static str {
        match self {
            ChunkType::Encrypted => "Encr",
            ChunkType::RawMessage => "RMsg",
        }
    }

    pub fn from_str(name: &str) -> Result<ChunkType, &'static str> {
        match name {
            "Encr" => Ok(ChunkType::Encrypted),
            "RMsg" => Ok(ChunkType::RawMessage),
            _ => Err("Not a valid chunk type!"),
        }
    }
}

And well, it warns me on every single item "xyz is never used". I don't think I am supposed to suppress the warning, right?
Have I done anything wrong? How to resolve this?

wild flax
#

I do

real ermine
#

is there mod chunk_type; there too?

wild flax
#

oh

#

Yes

#

there is

#

I removed it

#

now it works

#

lmao..?

#

Why tho

real ermine
#

each module should have exactly one declaration it the project

#

because it was compiled twice

wild flax
#

hmm I see

real ermine
#

you're supposed to use the library

wild flax
#

Well.. makes sense yea xD

#

So

#

this is still a bin project with a library wrapped inside it?

real ermine
#

by "project" I mean the whole project folder

#

there's a binary crate and library crate