# Override a trait for external struct with a out of scope method

**URL:** <https://users.rust-lang.org/t/override-a-trait-for-external-struct-with-a-out-of-scope-method/57805>\
**Category:** help\
**Created:** [April 2, 2021, 6:08pm UTC](https://users.rust-lang.org/t/override-a-trait-for-external-struct-with-a-out-of-scope-method/57805 "2021-04-02T18:08:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pejman](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@pejman](https://users.rust-lang.org/u/pejman)\
**Post date:** [April 2, 2021, 6:08pm UTC](https://users.rust-lang.org/t/override-a-trait-for-external-struct-with-a-out-of-scope-method/57805/1 "2021-04-02T18:08:39Z")

</div>

can someone help me?? i wanna override a trait for external struct with a method but i got an error because my method is undefined for scope of trait!!!

[qu|584x385](https://users.rust-lang.org/uploads/short-url/wofFPsXZwlMi25OqdmZcj9r8lNJ.png)

my question is how to call init function in scope of trait to obtain b and i can call method  
on b? i tried static for b but because a isn't constant i got an error.

---

<div class="post-metadata">

**Author:** ![Kestrer](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/kestrer/32/22688_2.png) [@Kestrer](https://users.rust-lang.org/u/Kestrer)\
**Post date:** [April 2, 2021, 6:35pm UTC](https://users.rust-lang.org/t/override-a-trait-for-external-struct-with-a-out-of-scope-method/57805/2 "2021-04-02T18:35:23Z")

</div>

This sounds like an [XY problem](https://xyproblem.info/) - what are you actually trying to do here? I also don't really see the relationship between `my_trait`, `external_struct`, `A` and `my_struct` in your code example, there's apparently nothing connecting them.

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/system/32/51372_2.png) [@system](https://users.rust-lang.org/u/system)\
**Post date:** [July 1, 2021, 6:36pm UTC](https://users.rust-lang.org/t/override-a-trait-for-external-struct-with-a-out-of-scope-method/57805/3 "2021-07-01T18:36:10Z")

</div>

Closed on July 1, 2021, 6:36pm UTC

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.
