title: Rust: cannot find macro
body: <p>I'm trying to run rust code from the <code>postgres_types</code> documentation.</p>
  
  <p>The example code can be found here: <a href="https://docs.rs/crate/postgres-types/0.1.0-alpha.1" rel="nofollow noreferrer">postgres_types</a></p>
  
  <p>my rust environment:</p>
  
  <blockquote>
    <p>cargo --version
    cargo 1.40.0-nightly (5da4b4d47 2019-10-28)</p>
    
    <p>rustc --version
    rustc 1.40.0-nightly (b520af6fd 2019-11-03)</p>
  </blockquote>
  
  <hr>
  
  <p>main.rs</p>
  
  <pre><code>#[cfg(feature = "derive")]
  use postgres_types::{ToSql, FromSql};
  
  #[derive(Debug, ToSql, FromSql)]
  enum Mood {
      Sad,
      Ok,
      Happy,
  }
  
  fn main() {
      let mood = Mood::Sad;
  
      println!("{:?}", mood);
  }
  </code></pre>
  
  <hr>
  
  <p>Cargo.toml</p>
  
  <pre><code>...
  
  [dependencies]
  postgres-types = "0.1.0-alpha.1"
  </code></pre>
  
  <hr>
  
  <p>When I try and run with <code>cargo run</code> I get:</p>
  
  <pre><code>error: cannot find derive macro `ToSql` in this scope
   --&gt; src\main.rs:4:17
    |
  4 | #[derive(Debug, ToSql, FromSql)]
    |                 ^^^^^
  
  error: cannot find derive macro `FromSql` in this scope
   --&gt; src\main.rs:4:24
    |
  4 | #[derive(Debug, ToSql, FromSql)]
    |                        ^^^^^^^
  </code></pre>
  
  <p>What am I doing wrong here? Clearly I'm missing something basic. Have I not imported the macro correctly?</p>