qdk_sim/lib.rs
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4// The following two attributes include the README.md for this crate when
5// building docs (requires +nightly).
6// See https://github.com/rust-lang/rust/issues/82768#issuecomment-803935643
7// for discussion.
8#![cfg_attr(doc, feature(extended_key_value_attributes))]
9#![cfg_attr(doc, cfg_attr(doc, doc = include_str!("../README.md")))]
10// Set linting rules for documentation. We will stop the build on missing docs,
11// or docs with known broken links. We only enable this when all relevant
12// features are enabled, otherwise the docs build will fail on links to
13// features that are disabled for the current build.
14#![cfg_attr(all(doc, feature = "python"), deny(rustdoc::broken_intra_doc_links))]
15#![cfg_attr(doc, deny(missing_docs))]
16// This linting rule raises a warning on any documentation comments
17// that are missing an `# Example` section. Currently, that raises a lot of
18// warnings when building docs, but ideally we should make sure to address
19// warnings going forward by adding relevant examples.
20#![cfg_attr(doc, warn(missing_doc_code_examples))]
21
22#[macro_use(array, s)]
23extern crate ndarray;
24
25extern crate derive_more;
26extern crate serde;
27use serde::{Deserialize, Serialize};
28use std::usize;
29
30pub mod c_api;
31mod chp_decompositions;
32pub mod common_matrices;
33mod instrument;
34pub mod linalg;
35mod noise_model;
36mod paulis;
37mod processes;
38mod states;
39mod tableau;
40mod utils;
41
42pub use crate::instrument::*;
43pub use crate::noise_model::NoiseModel;
44pub use crate::paulis::*;
45pub use crate::processes::*;
46pub use crate::states::{State, StateData};
47pub use crate::tableau::Tableau;
48pub use crate::utils::*;
49
50// When documenting, we want to make sure to expose the Python module as
51// public so that rustdoc can see its documentation. When the "python" crate
52// feature is off, the module shouldn't even be private.
53#[cfg(all(not(doc), feature = "python"))]
54mod python;
55#[cfg(all(doc, feature = "python"))]
56pub mod python;
57
58/// Represents that a given type has a size that can be measured in terms
59/// of a number of qubits (e.g.: [`State`]).
60#[derive(Clone, Debug, Serialize, Deserialize)]
61pub struct QubitSized<T> {
62 n_qubits: usize,
63 data: T,
64}
65
66impl<T> QubitSized<T> {
67 /// Returns the number of qubits that this value relates to.
68 pub fn get_n_qubits(&self) -> usize {
69 self.n_qubits
70 }
71}
72
73/// Metadata about how this crate was built.
74pub mod built_info {
75 include!(concat!(env!("OUT_DIR"), "/built.rs"));
76}