Skip to content

Conversation

japaric
Copy link
Contributor

@japaric japaric commented Mar 3, 2015

Associated types are now treated as part of the public API by the privacy checker.

If you were exposing a private type in your public API via an associated type, make that type public:

  pub struct PublicType { .. }

- struct Struct { .. }
+ pub struct Struct { .. }

  pub trait PublicTrait {
      type Output;

      fn foo(&self) -> Self::Output;
  }

  impl PublicTrait for PublicType {
      type Output = Struct;

      fn foo(&self) -> Struct {  // `Struct` is part of the public API, it must be marked as `pub`lic
          ..
      }
  }

[breaking-change]


r? @nikomatsakis
closes #22912

@alexcrichton
Copy link
Member

@bors: r+ 89776ae

Manishearth added a commit to Manishearth/rust that referenced this pull request Mar 3, 2015
 Associated types are now treated as part of the public API by the privacy checker.

If you were exposing a private type in your public API via an associated type, make that type public:

``` diff
  pub struct PublicType { .. }

- struct Struct { .. }
+ pub struct Struct { .. }

  pub trait PublicTrait {
      type Output;

      fn foo(&self) -> Self::Output;
  }

  impl PublicTrait for PublicType {
      type Output = Struct;

      fn foo(&self) -> Struct {  // `Struct` is part of the public API, it must be marked as `pub`lic
          ..
      }
  }
```

[breaking-change]

---

r? @nikomatsakis
closes rust-lang#22912
@bors bors merged commit 89776ae into rust-lang:master Mar 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Associated types lets you expose private types in public signatures (?)
4 participants