# 对于在modA中的对基本类型的扩展，如何在modB中自动引用？

**URL:** <https://taolun.moonbitlang.com/t/topic/1237>\
**Category:** MoonBit反馈\
**Created:** [2025 年6 月 10 日 15:27 UTC](https://taolun.moonbitlang.com/t/topic/1237 "2025-06-10T15:27:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

作者： ![bopomf](https://taolun.moonbitlang.com/letter_avatar_proxy/v4/letter/b/e19b73/32.png) [@bopomf](https://taolun.moonbitlang.com/u/bopomf)\
发布日期： [2025 年6 月 10 日 15:27 UTC](https://taolun.moonbitlang.com/t/topic/1237/1 "2025-06-10T15:27:14Z")

</div>

在modA中实现了对String的扩展比如String::to\_int(Self)-\>Int，在另一个modB中如何引用才能让modB中的String变量自动挂上我在modA中实现的对String的扩展？“123”.to\_int() 如何才能这样用？我不知道目前的依赖导入怎么做到自动挂上对类型的外部扩展

---

<div class="post-metadata">

作者： ![ChenYubin](https://taolun.moonbitlang.com/letter_avatar_proxy/v4/letter/c/ee59a6/32.png) [@ChenYubin](https://taolun.moonbitlang.com/u/ChenYubin)\
发布日期： [2025 年6 月 11 日 02:05 UTC](https://taolun.moonbitlang.com/t/topic/1237/2 "2025-06-11T02:05:09Z")

</div>

对一个外部的类型的`fn Type::method(Args) -> R`定义是local method，local method仅支持在同一个包内使用
