How to constructe a unit-like struct?


#1
pub struct ConsFactory;

impl ConsFactory {

    pub fn new() {
        ConsFactory()
    }

}

or

pub struct ConsFactory;

impl ConsFactory {

    pub fn new() {
        ConsFactory{}
    }

}

both not work.

I am confused…You guys say use {} to construct a struct, isn’t a unit -like struct A struct???


#2
    pub fn new() -> ConsFactory {
        ConsFactory
    }

#3

Thanks, the book should give an example.