Why can't I import my macro under another crates

I have a total of three crates, one of which is used to make macros, the other is the core crate, and there is a test crate

use mybatis;

use mybatis::{CRUDTable, crud_table};
use mybatis::{crud::CRUD};
use mybatis::mybatis_sql::string_util::to_snake_name;
use mybatis::mybatis::Mybatis;
use mybatis::snowflake::SNOWFLAKE;
use serde::{Serialize, Deserialize};

#[derive(Debug, Serialize, Deserialize)]
pub struct Pets {
    pub id: Option<String>,
    pub name: Option<String>,
    pub birthday: Option<mybatis::DateTimeNative>,
    pub delete_flag: Option<i32>,


failed to resolve: could not find `core` in `mybatis`
could not find `core` in `mybatis`rustcE0433
failed to resolve: could not find `core` in `mybatis`(E0433)

#[macro_use] only has an effect on extern crate and modules?

However, the "external crate" add-on must be located in the crate root directory. What if there are multiple creates lib

#[macro_use] and #[macro_export] are only used for macro_rules macros, and the existence of your mybatis-macro crate suggests that that is a proc-macro.

If it is indeed a proc-macro you can just import it as any other item.

1 Like

yes, mybatis-macro crate Cargo.toml file:

name = "mybatis-macro"
version = "1.0.3"
description = "mybatis macro driver"
authors = ["James Zow <jameszow@163.com>"]
edition = "2021"
license = "Apache-2.0"
rust-version = "1.59.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

default = []
debug_mode = []
proc-macro = true
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "1.0", features = ["full"] }
html_parser = "0.6.2"
base64 = "0.13.0"
url = "2.2.2"

I have to think it over, but you did remind me. Thank you very much

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.