Merge pull request #825 from lnicola/gate-doctests

Add feature gates for doctests
This commit is contained in:
Steven Fackler 2021-09-25 13:13:15 -04:00 committed by GitHub
commit 3854aecbb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -4,10 +4,12 @@
//!
//! ```no_run
//! use native_tls::{Certificate, TlsConnector};
//! # #[cfg(feature = "runtime")]
//! use postgres_native_tls::MakeTlsConnector;
//! use std::fs;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! # #[cfg(feature = "runtime")] {
//! let cert = fs::read("database_cert.pem")?;
//! let cert = Certificate::from_pem(&cert)?;
//! let connector = TlsConnector::builder()
@ -19,6 +21,7 @@
//! "host=localhost user=postgres sslmode=require",
//! connector,
//! );
//! # }
//!
//! // ...
//! # Ok(())
@ -27,10 +30,12 @@
//!
//! ```no_run
//! use native_tls::{Certificate, TlsConnector};
//! # #[cfg(feature = "runtime")]
//! use postgres_native_tls::MakeTlsConnector;
//! use std::fs;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! # #[cfg(feature = "runtime")] {
//! let cert = fs::read("database_cert.pem")?;
//! let cert = Certificate::from_pem(&cert)?;
//! let connector = TlsConnector::builder()
@ -42,6 +47,7 @@
//! "host=localhost user=postgres sslmode=require",
//! connector,
//! )?;
//! # }
//! # Ok(())
//! # }
//! ```

View File

@ -4,9 +4,11 @@
//!
//! ```no_run
//! use openssl::ssl::{SslConnector, SslMethod};
//! # #[cfg(feature = "runtime")]
//! use postgres_openssl::MakeTlsConnector;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! # #[cfg(feature = "runtime")] {
//! let mut builder = SslConnector::builder(SslMethod::tls())?;
//! builder.set_ca_file("database_cert.pem")?;
//! let connector = MakeTlsConnector::new(builder.build());
@ -15,6 +17,7 @@
//! "host=localhost user=postgres sslmode=require",
//! connector,
//! );
//! # }
//!
//! // ...
//! # Ok(())
@ -23,9 +26,11 @@
//!
//! ```no_run
//! use openssl::ssl::{SslConnector, SslMethod};
//! # #[cfg(feature = "runtime")]
//! use postgres_openssl::MakeTlsConnector;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! # #[cfg(feature = "runtime")] {
//! let mut builder = SslConnector::builder(SslMethod::tls())?;
//! builder.set_ca_file("database_cert.pem")?;
//! let connector = MakeTlsConnector::new(builder.build());
@ -34,6 +39,7 @@
//! "host=localhost user=postgres sslmode=require",
//! connector,
//! )?;
//! # }
//!
//! // ...
//! # Ok(())