Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrypto Importing Structs from other folder [duplicate]

In Scrypto, I have folder structure like:

src/
├── lib.rs
├── script.rs
├── custom_types
│   └── type.rs

In type.rs, I have the following defined:


use sbor::*;

#[derive(TypeId, Encode, Decode, Describe)]
pub struct Date {
    year: u8,
    day: u8,
    month: u8,
}

I want to be able to use the Date struct in script.rs how do I do it?

like image 771
M80 Avatar asked Nov 28 '25 17:11

M80


1 Answers

Organize files like:

src/
├── lib.rs
├── script.rs
├── custom_types
│   └── type.rs
│   └── mod.rs

mod.rs:

pub mod type;

Add the following to script.rs:

use super::custom_types::type::Date;

...

Finally, add the following to lib.rs

mod datatypes;
like image 70
M80 Avatar answered Dec 01 '25 16:12

M80



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!