зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1436058 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel
MozReview-Commit-ID: GiRingn0bX1 --HG-- extra : rebase_source : 55e472428534e366a49ccc887f67b8c7836171b1
This commit is contained in:
Родитель
dff724b60d
Коммит
e1dbbcbce0
|
@ -0,0 +1 @@
|
|||
{"files":{".travis.yml":"50f67b20a376d437e0706d9bbb0343c677295529991370b2962f814c0b2efea3","Cargo.toml":"d217067290b088db7f696e02ecc25461a0277e5e5e3bca6c7c0412b604c3526b","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"3fa9368c60bc701dea294fbacae0469188c4be1de79f82e972bb9b321776cd52","src/lib.rs":"74b287a91a46dc9d0c179053b439fd40c43ad5389fbd5199fff1cce0094726a6","tests/xcrate.rs":"30dcb70fbb9c96fda2b7825592558279f534776f72e2a8a0a3e26df4dedb3caa"},"package":"d0c47d456a36ebf0536a6705c83c1cbbcb9255fbc1d905a6ded104f479268a29"}
|
|
@ -0,0 +1,23 @@
|
|||
language: rust
|
||||
rust:
|
||||
- stable
|
||||
- beta
|
||||
- nightly
|
||||
sudo: false
|
||||
before_script:
|
||||
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
|
||||
script:
|
||||
- cargo build --verbose
|
||||
- cargo test --verbose
|
||||
- rustdoc --test README.md -L target/debug -L target/debug/deps
|
||||
- cargo doc --no-deps
|
||||
after_success:
|
||||
- travis-cargo --only nightly doc-upload
|
||||
env:
|
||||
global:
|
||||
secure: "TyMGH+sbPmKs9lKCziKShxWr3G6im0owEchVrbUChWnQIQv1WydXftFoEoUsVl6qZspjehWK1b1AsnIgCXK0HtEi4DnqLsxs0s36bOjfg5yHBT/pETTr6kcq7KAL4Be4GmI331k6gT1Oi0TPFp7Sg9xpiWsQqKIHA5Szk2wpFQ8="
|
||||
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "cfg-if"
|
||||
version = "0.1.1"
|
||||
authors = ["Alex Crichton <alex@alexcrichton.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/alexcrichton/cfg-if"
|
||||
homepage = "https://github.com/alexcrichton/cfg-if"
|
||||
documentation = "http://alexcrichton.com/cfg-if"
|
||||
description = """
|
||||
A macro to ergonomically define an item depending on a large number of #[cfg]
|
||||
parameters. Structured like an if-else chain, the first matching branch is the
|
||||
item that gets emitted.
|
||||
"""
|
|
@ -0,0 +1,201 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -0,0 +1,25 @@
|
|||
Copyright (c) 2014 Alex Crichton
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,44 @@
|
|||
# cfg-if
|
||||
|
||||
[![Build Status](https://travis-ci.org/alexcrichton/cfg-if.svg?branch=master)](https://travis-ci.org/alexcrichton/cfg-if)
|
||||
|
||||
[Documentation](http://alexcrichton.com/cfg-if)
|
||||
|
||||
A macro to ergonomically define an item depending on a large number of #[cfg]
|
||||
parameters. Structured like an if-else chain, the first matching branch is the
|
||||
item that gets emitted.
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
cfg-if = "0.1"
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```rust
|
||||
#[macro_use]
|
||||
extern crate cfg_if;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
fn foo() { /* unix specific functionality */ }
|
||||
} else if #[cfg(target_pointer_width = "32")] {
|
||||
fn foo() { /* non-unix, 32-bit functionality */ }
|
||||
} else {
|
||||
fn foo() { /* fallback implementation */ }
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
foo();
|
||||
}
|
||||
```
|
||||
|
||||
# License
|
||||
|
||||
`cfg-if` is primarily distributed under the terms of both the MIT license and
|
||||
the Apache License (Version 2.0), with portions covered by various BSD-like
|
||||
licenses.
|
||||
|
||||
See LICENSE-APACHE, and LICENSE-MIT for details.
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
//! A macro for defining #[cfg] if-else statements.
|
||||
//!
|
||||
//! The macro provided by this crate, `cfg_if`, is similar to the `if/elif` C
|
||||
//! preprocessor macro by allowing definition of a cascade of `#[cfg]` cases,
|
||||
//! emitting the implementation which matches first.
|
||||
//!
|
||||
//! This allows you to conveniently provide a long list #[cfg]'d blocks of code
|
||||
//! without having to rewrite each clause multiple times.
|
||||
//!
|
||||
//! # Example
|
||||
//!
|
||||
//! ```
|
||||
//! #[macro_use]
|
||||
//! extern crate cfg_if;
|
||||
//!
|
||||
//! cfg_if! {
|
||||
//! if #[cfg(unix)] {
|
||||
//! fn foo() { /* unix specific functionality */ }
|
||||
//! } else if #[cfg(target_pointer_width = "32")] {
|
||||
//! fn foo() { /* non-unix, 32-bit functionality */ }
|
||||
//! } else {
|
||||
//! fn foo() { /* fallback implementation */ }
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
//! # fn main() {}
|
||||
//! ```
|
||||
|
||||
#![no_std]
|
||||
|
||||
#![doc(html_root_url = "http://alexcrichton.com/cfg-if")]
|
||||
#![deny(missing_docs)]
|
||||
#![cfg_attr(test, deny(warnings))]
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! cfg_if {
|
||||
($(
|
||||
if #[cfg($($meta:meta),*)] { $($it:item)* }
|
||||
) else * else {
|
||||
$($it2:item)*
|
||||
}) => {
|
||||
__cfg_if_items! {
|
||||
() ;
|
||||
$( ( ($($meta),*) ($($it)*) ), )*
|
||||
( () ($($it2)*) ),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __cfg_if_items {
|
||||
(($($not:meta,)*) ; ) => {};
|
||||
(($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ), $($rest:tt)*) => {
|
||||
__cfg_if_apply! { cfg(all($($m,)* not(any($($not),*)))), $($it)* }
|
||||
__cfg_if_items! { ($($not,)* $($m,)*) ; $($rest)* }
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __cfg_if_apply {
|
||||
($m:meta, $($it:item)*) => {
|
||||
$(#[$m] $it)*
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
cfg_if! {
|
||||
if #[cfg(test)] {
|
||||
use core::option::Option as Option2;
|
||||
fn works1() -> Option2<u32> { Some(1) }
|
||||
} else {
|
||||
fn works1() -> Option<u32> { None }
|
||||
}
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(foo)] {
|
||||
fn works2() -> bool { false }
|
||||
} else if #[cfg(test)] {
|
||||
fn works2() -> bool { true }
|
||||
} else {
|
||||
fn works2() -> bool { false }
|
||||
}
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(foo)] {
|
||||
fn works3() -> bool { false }
|
||||
} else {
|
||||
fn works3() -> bool { true }
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
assert!(works1().is_some());
|
||||
assert!(works2());
|
||||
assert!(works3());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#[macro_use]
|
||||
extern crate cfg_if;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(foo)] {
|
||||
fn works() -> bool { false }
|
||||
} else if #[cfg(test)] {
|
||||
fn works() -> bool { true }
|
||||
} else {
|
||||
fn works() -> bool { false }
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn smoke() {
|
||||
assert!(works());
|
||||
}
|
|
@ -1 +1 @@
|
|||
{"files":{".travis.yml":"50f67b20a376d437e0706d9bbb0343c677295529991370b2962f814c0b2efea3","Cargo.toml":"d217067290b088db7f696e02ecc25461a0277e5e5e3bca6c7c0412b604c3526b","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"3fa9368c60bc701dea294fbacae0469188c4be1de79f82e972bb9b321776cd52","src/lib.rs":"74b287a91a46dc9d0c179053b439fd40c43ad5389fbd5199fff1cce0094726a6","tests/xcrate.rs":"30dcb70fbb9c96fda2b7825592558279f534776f72e2a8a0a3e26df4dedb3caa"},"package":"d0c47d456a36ebf0536a6705c83c1cbbcb9255fbc1d905a6ded104f479268a29"}
|
||||
{"files":{".travis.yml":"50f67b20a376d437e0706d9bbb0343c677295529991370b2962f814c0b2efea3","Cargo.toml":"764b9ce160653e841430da3919ff968b957ff811f7da42c8483c8bfc2f06be25","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"3fa9368c60bc701dea294fbacae0469188c4be1de79f82e972bb9b321776cd52","src/lib.rs":"6915169e3ca05f28e1cb0e052379d74f2496400de1240b74c56e55c2674a6560","tests/xcrate.rs":"30dcb70fbb9c96fda2b7825592558279f534776f72e2a8a0a3e26df4dedb3caa"},"package":"d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"}
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "cfg-if"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
authors = ["Alex Crichton <alex@alexcrichton.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
|
|
@ -44,6 +44,19 @@ macro_rules! cfg_if {
|
|||
$( ( ($($meta),*) ($($it)*) ), )*
|
||||
( () ($($it2)*) ),
|
||||
}
|
||||
};
|
||||
(
|
||||
if #[cfg($($i_met:meta),*)] { $($i_it:item)* }
|
||||
$(
|
||||
else if #[cfg($($e_met:meta),*)] { $($e_it:item)* }
|
||||
)*
|
||||
) => {
|
||||
__cfg_if_items! {
|
||||
() ;
|
||||
( ($($i_met),*) ($($i_it)*) ),
|
||||
$( ( ($($e_met),*) ($($e_it)*) ), )*
|
||||
( () () ),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,10 +107,27 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(test)] {
|
||||
use core::option::Option as Option3;
|
||||
fn works4() -> Option3<u32> { Some(1) }
|
||||
}
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(foo)] {
|
||||
fn works5() -> bool { false }
|
||||
} else if #[cfg(test)] {
|
||||
fn works5() -> bool { true }
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
assert!(works1().is_some());
|
||||
assert!(works2());
|
||||
assert!(works3());
|
||||
assert!(works4().is_some());
|
||||
assert!(works5());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{".travis.yml":"6aad961651169d31d79c0595624d1777b5c4cbb4cf2bed9a126c7e72d29411fd","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"7b694b4c2584d66e353968c93b4d639b7cbee87595b7323d721338299c2f80ec","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"0c82015d302c9937e6376debd961350afeaeb6dde228aac95e3a3115c5813613","src/font.rs":"de24c0023079289752a2fdb435012ba77982c108695d931926e6b629f0a7863a","src/font_collection.rs":"640402b679756d4cbf868d2cb96bb8c77f363ee36c42f7584d831a923c9006a2","src/font_descriptor.rs":"71781af6b428278bd1ed2a13e3aafa4be8f263e835c879016e697c5bc4104de8","src/font_manager.rs":"de5e22620528322d6811d01f03975c53b676ec743297590de5e17a45393df0f1","src/lib.rs":"dfff85c1e4dbbc5d360dd022a8e539be4e5f195d8695467e1dcb25bd0bac4f47"},"package":"2c737a5c1f112943c961ed270aea64f7d0b01b425d327b040fa32b155646e07f"}
|
||||
{"files":{".travis.yml":"6aad961651169d31d79c0595624d1777b5c4cbb4cf2bed9a126c7e72d29411fd","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"7a7725d84ea421fd0b48ddaa17e6abe58e3dd1507232dc03a76e2fbcb305ebd2","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"0c82015d302c9937e6376debd961350afeaeb6dde228aac95e3a3115c5813613","src/font.rs":"640f17efb3492ad0e9c318a4e2e23da87120f817d055475290e2f58f0212577d","src/font_collection.rs":"4fbe6a45d227771e148498bab5f915bd6e7cb6f060427b8f4ac626a44fcee288","src/font_descriptor.rs":"188dfad16e1081ec411dbdce1d8210be187a2dac0cf983444f01d5122e7d8e6e","src/font_manager.rs":"de5e22620528322d6811d01f03975c53b676ec743297590de5e17a45393df0f1","src/lib.rs":"bd072cf53ebb643e4d21379d4487e60745999d20eab9caee8e56daa430cb65ca"},"package":"2bd581c37283d0c23311d179aefbb891f2324ee0405da58a26e8594ab76e5748"}
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
[package]
|
||||
name = "core-text"
|
||||
version = "9.0.0"
|
||||
version = "9.2.0"
|
||||
authors = ["The Servo Project Developers"]
|
||||
description = "Bindings to the Core Text framework."
|
||||
license = "MIT/Apache-2.0"
|
||||
|
|
|
@ -9,13 +9,14 @@
|
|||
|
||||
#![allow(non_upper_case_globals)]
|
||||
|
||||
use font_descriptor;
|
||||
use font_descriptor::{CTFontDescriptor, CTFontDescriptorRef, CTFontOrientation};
|
||||
use font_descriptor::{CTFontSymbolicTraits, CTFontTraits, SymbolicTraitAccessors, TraitAccessors};
|
||||
|
||||
use core_foundation::array::{CFArray, CFArrayRef};
|
||||
use core_foundation::base::{CFIndex, CFOptionFlags, CFTypeID, CFRelease, CFRetain, CFTypeRef, TCFType};
|
||||
use core_foundation::base::{CFIndex, CFOptionFlags, CFTypeID, CFTypeRef, TCFType};
|
||||
use core_foundation::data::{CFData, CFDataRef};
|
||||
use core_foundation::dictionary::CFDictionaryRef;
|
||||
use core_foundation::dictionary::{CFDictionary, CFDictionaryRef};
|
||||
use core_foundation::string::{CFString, CFStringRef, UniChar};
|
||||
use core_foundation::url::{CFURL, CFURLRef};
|
||||
use core_graphics::base::CGFloat;
|
||||
|
@ -26,7 +27,6 @@ use core_graphics::path::CGPath;
|
|||
|
||||
use foreign_types::ForeignType;
|
||||
use libc::{self, size_t, c_void};
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
type CGContextRef = *mut <CGContext as ForeignType>::CType;
|
||||
|
@ -80,63 +80,11 @@ pub struct __CTFont(c_void);
|
|||
|
||||
pub type CTFontRef = *const __CTFont;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CTFont {
|
||||
obj: CTFontRef,
|
||||
}
|
||||
|
||||
impl Drop for CTFont {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
CFRelease(self.as_CFTypeRef())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for CTFont {
|
||||
#[inline]
|
||||
fn clone(&self) -> CTFont {
|
||||
unsafe {
|
||||
TCFType::wrap_under_get_rule(self.obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TCFType for CTFont {
|
||||
type Ref = CTFontRef;
|
||||
|
||||
#[inline]
|
||||
fn as_concrete_TypeRef(&self) -> CTFontRef {
|
||||
self.obj
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn wrap_under_get_rule(reference: CTFontRef) -> CTFont {
|
||||
let reference: CTFontRef = mem::transmute(CFRetain(mem::transmute(reference)));
|
||||
TCFType::wrap_under_create_rule(reference)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn wrap_under_create_rule(obj: CTFontRef) -> CTFont {
|
||||
CTFont {
|
||||
obj: obj,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn as_CFTypeRef(&self) -> CFTypeRef {
|
||||
unsafe {
|
||||
mem::transmute(self.as_concrete_TypeRef())
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn type_id() -> CFTypeID {
|
||||
unsafe {
|
||||
CTFontGetTypeID()
|
||||
}
|
||||
}
|
||||
declare_TCFType! {
|
||||
CTFont, CTFontRef
|
||||
}
|
||||
impl_TCFType!(CTFont, CTFontRef, CTFontGetTypeID);
|
||||
impl_CFTypeDescription!(CTFont);
|
||||
|
||||
pub fn new_from_CGFont(cgfont: &CGFont, pt_size: f64) -> CTFont {
|
||||
unsafe {
|
||||
|
@ -144,7 +92,21 @@ pub fn new_from_CGFont(cgfont: &CGFont, pt_size: f64) -> CTFont {
|
|||
pt_size as CGFloat,
|
||||
ptr::null(),
|
||||
ptr::null());
|
||||
TCFType::wrap_under_create_rule(font_ref)
|
||||
CTFont::wrap_under_create_rule(font_ref)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_from_CGFont_with_variations(cgfont: &CGFont,
|
||||
pt_size: f64,
|
||||
variations: &CFDictionary)
|
||||
-> CTFont {
|
||||
unsafe {
|
||||
let font_desc = font_descriptor::new_from_variations(variations);
|
||||
let font_ref = CTFontCreateWithGraphicsFont(cgfont.as_ptr() as *mut _,
|
||||
pt_size as CGFloat,
|
||||
ptr::null(),
|
||||
font_desc.as_concrete_TypeRef());
|
||||
CTFont::wrap_under_create_rule(font_ref)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,7 +115,7 @@ pub fn new_from_descriptor(desc: &CTFontDescriptor, pt_size: f64) -> CTFont {
|
|||
let font_ref = CTFontCreateWithFontDescriptor(desc.as_concrete_TypeRef(),
|
||||
pt_size as CGFloat,
|
||||
ptr::null());
|
||||
TCFType::wrap_under_create_rule(font_ref)
|
||||
CTFont::wrap_under_create_rule(font_ref)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,7 +128,7 @@ pub fn new_from_name(name: &str, pt_size: f64) -> Result<CTFont, ()> {
|
|||
if font_ref.is_null() {
|
||||
Err(())
|
||||
} else {
|
||||
Ok(TCFType::wrap_under_create_rule(font_ref))
|
||||
Ok(CTFont::wrap_under_create_rule(font_ref))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +137,7 @@ impl CTFont {
|
|||
// Properties
|
||||
pub fn symbolic_traits(&self) -> CTFontSymbolicTraits {
|
||||
unsafe {
|
||||
CTFontGetSymbolicTraits(self.obj)
|
||||
CTFontGetSymbolicTraits(self.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -184,18 +146,18 @@ impl CTFont {
|
|||
// Creation methods
|
||||
pub fn copy_to_CGFont(&self) -> CGFont {
|
||||
unsafe {
|
||||
let cgfont_ref = CTFontCopyGraphicsFont(self.obj, ptr::null_mut());
|
||||
let cgfont_ref = CTFontCopyGraphicsFont(self.0, ptr::null_mut());
|
||||
CGFont::from_ptr(cgfont_ref as *mut _)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clone_with_font_size(&self, size: f64) -> CTFont {
|
||||
unsafe {
|
||||
let font_ref = CTFontCreateCopyWithAttributes(self.obj,
|
||||
let font_ref = CTFontCreateCopyWithAttributes(self.0,
|
||||
size as CGFloat,
|
||||
ptr::null(),
|
||||
ptr::null());
|
||||
TCFType::wrap_under_create_rule(font_ref)
|
||||
CTFont::wrap_under_create_rule(font_ref)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -230,69 +192,69 @@ impl CTFont {
|
|||
|
||||
pub fn all_traits(&self) -> CTFontTraits {
|
||||
unsafe {
|
||||
TCFType::wrap_under_create_rule(CTFontCopyTraits(self.obj))
|
||||
CTFontTraits::wrap_under_create_rule(CTFontCopyTraits(self.0))
|
||||
}
|
||||
}
|
||||
|
||||
// Font metrics
|
||||
pub fn ascent(&self) -> CGFloat {
|
||||
unsafe {
|
||||
CTFontGetAscent(self.obj)
|
||||
CTFontGetAscent(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn descent(&self) -> CGFloat {
|
||||
unsafe {
|
||||
CTFontGetDescent(self.obj)
|
||||
CTFontGetDescent(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn underline_thickness(&self) -> CGFloat {
|
||||
unsafe {
|
||||
CTFontGetUnderlineThickness(self.obj)
|
||||
CTFontGetUnderlineThickness(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn underline_position(&self) -> CGFloat {
|
||||
unsafe {
|
||||
CTFontGetUnderlinePosition(self.obj)
|
||||
CTFontGetUnderlinePosition(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bounding_box(&self) -> CGRect {
|
||||
unsafe {
|
||||
CTFontGetBoundingBox(self.obj)
|
||||
CTFontGetBoundingBox(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn leading(&self) -> CGFloat {
|
||||
unsafe {
|
||||
CTFontGetLeading(self.obj)
|
||||
CTFontGetLeading(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn units_per_em(&self) -> libc::c_uint {
|
||||
unsafe {
|
||||
CTFontGetUnitsPerEm(self.obj)
|
||||
CTFontGetUnitsPerEm(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn x_height(&self) -> CGFloat {
|
||||
unsafe {
|
||||
CTFontGetXHeight(self.obj)
|
||||
CTFontGetXHeight(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pt_size(&self) -> CGFloat {
|
||||
unsafe {
|
||||
CTFontGetSize(self.obj)
|
||||
CTFontGetSize(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_glyphs_for_characters(&self, characters: *const UniChar, glyphs: *mut CGGlyph, count: CFIndex)
|
||||
-> bool {
|
||||
unsafe {
|
||||
CTFontGetGlyphsForCharacters(self.obj, characters, glyphs, count)
|
||||
CTFontGetGlyphsForCharacters(self.0, characters, glyphs, count)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -303,19 +265,19 @@ impl CTFont {
|
|||
count: CFIndex)
|
||||
-> f64 {
|
||||
unsafe {
|
||||
CTFontGetAdvancesForGlyphs(self.obj, orientation, glyphs, advances, count) as f64
|
||||
CTFontGetAdvancesForGlyphs(self.0, orientation, glyphs, advances, count) as f64
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_font_table(&self, tag: u32) -> Option<CFData> {
|
||||
unsafe {
|
||||
let result = CTFontCopyTable(self.obj,
|
||||
let result = CTFontCopyTable(self.0,
|
||||
tag as CTFontTableTag,
|
||||
kCTFontTableOptionsExcludeSynthetic);
|
||||
if result.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(TCFType::wrap_under_create_rule(result))
|
||||
Some(CFData::wrap_under_create_rule(result))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -345,11 +307,11 @@ impl CTFont {
|
|||
|
||||
pub fn url(&self) -> Option<CFURL> {
|
||||
unsafe {
|
||||
let result = CTFontCopyAttribute(self.obj, kCTFontURLAttribute);
|
||||
let result = CTFontCopyAttribute(self.0, kCTFontURLAttribute);
|
||||
if result.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(TCFType::wrap_under_create_rule(result as CFURLRef))
|
||||
Some(CFURL::wrap_under_create_rule(result as CFURLRef))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -357,7 +319,7 @@ impl CTFont {
|
|||
pub fn create_path_for_glyph(&self, glyph: CGGlyph, matrix: &CGAffineTransform)
|
||||
-> Result<CGPath, ()> {
|
||||
unsafe {
|
||||
let path = CTFontCreatePathForGlyph(self.obj, glyph, matrix);
|
||||
let path = CTFontCreatePathForGlyph(self.0, glyph, matrix);
|
||||
if path.is_null() {
|
||||
Err(())
|
||||
} else {
|
||||
|
@ -374,8 +336,7 @@ fn get_string_by_name_key(font: &CTFont, name_key: CFStringRef) -> Option<String
|
|||
if result.is_null() {
|
||||
None
|
||||
} else {
|
||||
let string: CFString = TCFType::wrap_under_create_rule(result);
|
||||
Some(string.to_string())
|
||||
Some(CFString::wrap_under_create_rule(result).to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -415,7 +376,7 @@ pub fn cascade_list_for_languages(font: &CTFont, language_pref_list: &CFArray<CF
|
|||
let font_collection_ref =
|
||||
CTFontCopyDefaultCascadeListForLanguages(font.as_concrete_TypeRef(),
|
||||
language_pref_list.as_concrete_TypeRef());
|
||||
TCFType::wrap_under_create_rule(font_collection_ref)
|
||||
CFArray::wrap_under_create_rule(font_collection_ref)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -472,7 +433,7 @@ extern {
|
|||
matrix: *const CGAffineTransform) -> CTFontRef;
|
||||
//fn CTFontCreateWithFontDescriptorAndOptions
|
||||
//fn CTFontCreateUIFontForLanguage
|
||||
fn CTFontCreateCopyWithAttributes(font: CTFontRef, size: CGFloat, matrix: *const CGAffineTransform,
|
||||
fn CTFontCreateCopyWithAttributes(font: CTFontRef, size: CGFloat, matrix: *const CGAffineTransform,
|
||||
attributes: CTFontDescriptorRef) -> CTFontRef;
|
||||
//fn CTFontCreateCopyWithSymbolicTraits
|
||||
//fn CTFontCreateCopyWithFamily
|
||||
|
@ -492,7 +453,7 @@ extern {
|
|||
//fn CTFontCopyFullName(font: CTFontRef) -> CFStringRef;
|
||||
//fn CTFontCopyDisplayName(font: CTFontRef) -> CFStringRef;
|
||||
fn CTFontCopyName(font: CTFontRef, nameKey: CFStringRef) -> CFStringRef;
|
||||
//fn CTFontCopyLocalizedName(font: CTFontRef, nameKey: CFStringRef,
|
||||
//fn CTFontCopyLocalizedName(font: CTFontRef, nameKey: CFStringRef,
|
||||
// language: *CFStringRef) -> CFStringRef;
|
||||
#[cfg(feature = "mountainlion")]
|
||||
fn CTFontCopyDefaultCascadeListForLanguages(font: CTFontRef, languagePrefList: CFArrayRef) -> CFArrayRef;
|
||||
|
@ -549,8 +510,8 @@ extern {
|
|||
/* Converting Fonts */
|
||||
fn CTFontCopyGraphicsFont(font: CTFontRef, attributes: *mut CTFontDescriptorRef)
|
||||
-> CGFontRef;
|
||||
fn CTFontCreateWithGraphicsFont(graphicsFont: CGFontRef, size: CGFloat,
|
||||
matrix: *const CGAffineTransform,
|
||||
fn CTFontCreateWithGraphicsFont(graphicsFont: CGFontRef, size: CGFloat,
|
||||
matrix: *const CGAffineTransform,
|
||||
attributes: CTFontDescriptorRef) -> CTFontRef;
|
||||
//fn CTFontGetPlatformFont
|
||||
//fn CTFontCreateWithPlatformFont
|
||||
|
|
|
@ -12,14 +12,13 @@ use font_descriptor::{CTFontDescriptor, CTFontDescriptorCreateMatchingFontDescri
|
|||
use font_manager::CTFontManagerCopyAvailableFontFamilyNames;
|
||||
|
||||
use core_foundation::array::{CFArray, CFArrayRef};
|
||||
use core_foundation::base::{CFRelease, CFRetain, CFTypeID, CFTypeRef, TCFType};
|
||||
use core_foundation::base::{CFTypeID, TCFType};
|
||||
use core_foundation::dictionary::{CFDictionary, CFDictionaryRef};
|
||||
use core_foundation::number::CFNumber;
|
||||
use core_foundation::set::CFSet;
|
||||
use core_foundation::string::{CFString, CFStringRef};
|
||||
|
||||
use libc::c_void;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -27,85 +26,43 @@ pub struct __CTFontCollection(c_void);
|
|||
|
||||
pub type CTFontCollectionRef = *const __CTFontCollection;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CTFontCollection {
|
||||
obj: CTFontCollectionRef,
|
||||
declare_TCFType! {
|
||||
CTFontCollection, CTFontCollectionRef
|
||||
}
|
||||
impl_TCFType!(CTFontCollection, CTFontCollectionRef, CTFontCollectionGetTypeID);
|
||||
impl_CFTypeDescription!(CTFontCollection);
|
||||
|
||||
impl Drop for CTFontCollection {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
CFRelease(self.as_CFTypeRef())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TCFType for CTFontCollection {
|
||||
type Ref = CTFontCollectionRef;
|
||||
|
||||
#[inline]
|
||||
fn as_concrete_TypeRef(&self) -> CTFontCollectionRef {
|
||||
self.obj
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn wrap_under_get_rule(reference: CTFontCollectionRef) -> CTFontCollection {
|
||||
let reference: CTFontCollectionRef = mem::transmute(CFRetain(mem::transmute(reference)));
|
||||
TCFType::wrap_under_create_rule(reference)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn wrap_under_create_rule(obj: CTFontCollectionRef) -> CTFontCollection {
|
||||
CTFontCollection {
|
||||
obj: obj,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn as_CFTypeRef(&self) -> CFTypeRef {
|
||||
unsafe {
|
||||
mem::transmute(self.as_concrete_TypeRef())
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn type_id() -> CFTypeID {
|
||||
unsafe {
|
||||
CTFontCollectionGetTypeID()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CTFontCollection {
|
||||
pub fn get_descriptors(&self) -> CFArray<CTFontDescriptor> {
|
||||
// surprise! this function follows the Get rule, despite being named *Create*.
|
||||
// So we have to addRef it to avoid CTFontCollection from double freeing it later.
|
||||
unsafe {
|
||||
TCFType::wrap_under_get_rule(CTFontCollectionCreateMatchingFontDescriptors(self.obj))
|
||||
CFArray::wrap_under_get_rule(CTFontCollectionCreateMatchingFontDescriptors(self.0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_from_descriptors(descs: &CFArray<CTFontDescriptor>) -> CTFontCollection {
|
||||
unsafe {
|
||||
let key: CFString = TCFType::wrap_under_get_rule(kCTFontCollectionRemoveDuplicatesOption);
|
||||
let key = CFString::wrap_under_get_rule(kCTFontCollectionRemoveDuplicatesOption);
|
||||
let value = CFNumber::from(1i64);
|
||||
let options = CFDictionary::from_CFType_pairs(&[ (key.as_CFType(), value.as_CFType()) ]);
|
||||
let font_collection_ref =
|
||||
CTFontCollectionCreateWithFontDescriptors(descs.as_concrete_TypeRef(),
|
||||
options.as_concrete_TypeRef());
|
||||
TCFType::wrap_under_create_rule(font_collection_ref)
|
||||
CTFontCollection::wrap_under_create_rule(font_collection_ref)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_for_all_families() -> CTFontCollection {
|
||||
unsafe {
|
||||
let key: CFString = TCFType::wrap_under_get_rule(kCTFontCollectionRemoveDuplicatesOption);
|
||||
let key = CFString::wrap_under_get_rule(kCTFontCollectionRemoveDuplicatesOption);
|
||||
let value = CFNumber::from(1i64);
|
||||
let options = CFDictionary::from_CFType_pairs(&[ (key.as_CFType(), value.as_CFType()) ]);
|
||||
let font_collection_ref =
|
||||
CTFontCollectionCreateFromAvailableFonts(options.as_concrete_TypeRef());
|
||||
TCFType::wrap_under_create_rule(font_collection_ref)
|
||||
CTFontCollection::wrap_under_create_rule(font_collection_ref)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +70,7 @@ pub fn create_for_family(family: &str) -> Option<CTFontCollection> {
|
|||
use font_descriptor::kCTFontFamilyNameAttribute;
|
||||
|
||||
unsafe {
|
||||
let family_attr: CFString = TCFType::wrap_under_get_rule(kCTFontFamilyNameAttribute);
|
||||
let family_attr = CFString::wrap_under_get_rule(kCTFontFamilyNameAttribute);
|
||||
let family_name: CFString = family.parse().unwrap();
|
||||
let specified_attrs = CFDictionary::from_CFType_pairs(&[
|
||||
(family_attr.as_CFType(), family_name.as_CFType())
|
||||
|
@ -128,7 +85,7 @@ pub fn create_for_family(family: &str) -> Option<CTFontCollection> {
|
|||
if matched_descs == ptr::null() {
|
||||
return None;
|
||||
}
|
||||
let matched_descs: CFArray<CTFontDescriptor> = TCFType::wrap_under_create_rule(matched_descs);
|
||||
let matched_descs = CFArray::wrap_under_create_rule(matched_descs);
|
||||
// I suppose one doesn't even need the CTFontCollection object at this point.
|
||||
// But we stick descriptors into and out of it just to provide a nice wrapper API.
|
||||
Some(new_from_descriptors(&matched_descs))
|
||||
|
@ -137,7 +94,7 @@ pub fn create_for_family(family: &str) -> Option<CTFontCollection> {
|
|||
|
||||
pub fn get_family_names() -> CFArray<CFString> {
|
||||
unsafe {
|
||||
TCFType::wrap_under_create_rule(CTFontManagerCopyAvailableFontFamilyNames())
|
||||
CFArray::wrap_under_create_rule(CTFontManagerCopyAvailableFontFamilyNames())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,7 +109,7 @@ extern {
|
|||
// descriptors: CFArrayRef,
|
||||
// options: CFDictionaryRef) -> CTFontCollectionRef;
|
||||
fn CTFontCollectionCreateFromAvailableFonts(options: CFDictionaryRef) -> CTFontCollectionRef;
|
||||
// this stupid function doesn't actually do any wildcard expansion;
|
||||
// this stupid function doesn't actually do any wildcard expansion;
|
||||
// it just chooses the best match. Use
|
||||
// CTFontDescriptorCreateMatchingDescriptors instead.
|
||||
fn CTFontCollectionCreateMatchingFontDescriptors(collection: CTFontCollectionRef) -> CFArrayRef;
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
#![allow(non_upper_case_globals)]
|
||||
|
||||
use core_foundation::array::CFArrayRef;
|
||||
use core_foundation::base::{CFRelease, CFRetain, CFType, CFTypeID, CFTypeRef, TCFType};
|
||||
use core_foundation::base::{CFType, CFTypeID, CFTypeRef, TCFType};
|
||||
use core_foundation::dictionary::{CFDictionary, CFDictionaryRef};
|
||||
use core_foundation::number::{CFNumber, CFNumberRef};
|
||||
use core_foundation::set::CFSetRef;
|
||||
use core_foundation::string::{CFString, CFStringRef};
|
||||
use core_foundation::url::CFURL;
|
||||
use core_foundation::url::{CFURLCopyFileSystemPath, kCFURLPOSIXPathStyle, CFURL};
|
||||
use core_graphics::base::CGFloat;
|
||||
|
||||
use libc::c_void;
|
||||
|
@ -131,7 +131,7 @@ impl TraitAccessorPrivate for CTFontTraits {
|
|||
unsafe fn extract_number_for_key(&self, key: CFStringRef) -> CFNumber {
|
||||
let cftype = self.get_CFType(mem::transmute(key));
|
||||
assert!(cftype.instance_of::<CFNumber>());
|
||||
TCFType::wrap_under_get_rule(mem::transmute(cftype.as_CFTypeRef()))
|
||||
CFNumber::wrap_under_get_rule(mem::transmute(cftype.as_CFTypeRef()))
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -187,66 +187,24 @@ pub struct __CTFontDescriptor(c_void);
|
|||
|
||||
pub type CTFontDescriptorRef = *const __CTFontDescriptor;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CTFontDescriptor {
|
||||
obj: CTFontDescriptorRef,
|
||||
declare_TCFType! {
|
||||
CTFontDescriptor, CTFontDescriptorRef
|
||||
}
|
||||
impl_TCFType!(CTFontDescriptor, CTFontDescriptorRef, CTFontDescriptorGetTypeID);
|
||||
impl_CFTypeDescription!(CTFontDescriptor);
|
||||
|
||||
impl Drop for CTFontDescriptor {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
CFRelease(self.as_CFTypeRef())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TCFType for CTFontDescriptor {
|
||||
type Ref = CTFontDescriptorRef;
|
||||
|
||||
#[inline]
|
||||
fn as_concrete_TypeRef(&self) -> CTFontDescriptorRef {
|
||||
self.obj
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn wrap_under_get_rule(reference: CTFontDescriptorRef) -> CTFontDescriptor {
|
||||
let reference: CTFontDescriptorRef = mem::transmute(CFRetain(mem::transmute(reference)));
|
||||
TCFType::wrap_under_create_rule(reference)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn as_CFTypeRef(&self) -> CFTypeRef {
|
||||
unsafe {
|
||||
mem::transmute(self.as_concrete_TypeRef())
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn wrap_under_create_rule(obj: CTFontDescriptorRef) -> CTFontDescriptor {
|
||||
CTFontDescriptor {
|
||||
obj: obj,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn type_id() -> CFTypeID {
|
||||
unsafe {
|
||||
CTFontDescriptorGetTypeID()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CTFontDescriptor {
|
||||
fn get_string_attribute(&self, attribute: CFStringRef) -> Option<String> {
|
||||
unsafe {
|
||||
let value = CTFontDescriptorCopyAttribute(self.obj, attribute);
|
||||
let value = CTFontDescriptorCopyAttribute(self.0, attribute);
|
||||
if value.is_null() {
|
||||
return None
|
||||
}
|
||||
|
||||
let value: CFType = TCFType::wrap_under_get_rule(value);
|
||||
let value = CFType::wrap_under_create_rule(value);
|
||||
assert!(value.instance_of::<CFString>());
|
||||
let s: CFString = TCFType::wrap_under_get_rule(mem::transmute(value.as_CFTypeRef()));
|
||||
let s = CFString::wrap_under_get_rule(mem::transmute(value.as_CFTypeRef()));
|
||||
Some(s.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -284,15 +242,29 @@ impl CTFontDescriptor {
|
|||
|
||||
pub fn font_path(&self) -> Option<String> {
|
||||
unsafe {
|
||||
let value = CTFontDescriptorCopyAttribute(self.obj, kCTFontURLAttribute);
|
||||
let value = CTFontDescriptorCopyAttribute(self.0, kCTFontURLAttribute);
|
||||
if value.is_null() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let value: CFType = TCFType::wrap_under_get_rule(value);
|
||||
let value = CFType::wrap_under_create_rule(value);
|
||||
assert!(value.instance_of::<CFURL>());
|
||||
let url: CFURL = TCFType::wrap_under_get_rule(mem::transmute(value.as_CFTypeRef()));
|
||||
Some(format!("{:?}", url))
|
||||
let url = CFURL::wrap_under_get_rule(mem::transmute(value.as_CFTypeRef()));
|
||||
let path = CFString::wrap_under_create_rule(CFURLCopyFileSystemPath(
|
||||
url.as_concrete_TypeRef(),
|
||||
kCFURLPOSIXPathStyle,
|
||||
)).to_string();
|
||||
Some(path)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn traits(&self) -> CTFontTraits {
|
||||
unsafe {
|
||||
let value = CTFontDescriptorCopyAttribute(self.0, kCTFontTraitsAttribute);
|
||||
assert!(!value.is_null());
|
||||
let value = CFType::wrap_under_create_rule(value);
|
||||
assert!(value.instance_of::<CFDictionary>());
|
||||
CFDictionary::wrap_under_get_rule(mem::transmute(value.as_CFTypeRef()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -301,7 +273,16 @@ pub fn new_from_attributes(attributes: &CFDictionary) -> CTFontDescriptor {
|
|||
unsafe {
|
||||
let result: CTFontDescriptorRef =
|
||||
CTFontDescriptorCreateWithAttributes(attributes.as_concrete_TypeRef());
|
||||
TCFType::wrap_under_create_rule(result)
|
||||
CTFontDescriptor::wrap_under_create_rule(result)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_from_variations(variations: &CFDictionary) -> CTFontDescriptor {
|
||||
unsafe {
|
||||
let var_key = CFType::wrap_under_get_rule(mem::transmute(kCTFontVariationAttribute));
|
||||
let var_val = CFType::wrap_under_get_rule(variations.as_CFTypeRef());
|
||||
let attributes = CFDictionary::from_CFType_pairs(&[(var_key, var_val)]);
|
||||
new_from_attributes(&attributes)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
extern crate foreign_types;
|
||||
extern crate libc;
|
||||
|
||||
#[macro_use]
|
||||
extern crate core_foundation;
|
||||
extern crate core_graphics;
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{"files":{".travis.yml":"985cf95c79f32c65766927fd6ef5079f8c14f235ddb4213e6410d90a86a95811","Cargo.toml":"0a4a756f7ef47f5dfa221a173b21f9ec496b448aafcd9bde08d9d16935b55007","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"aa8356455efcc3d49f66e7fa394eac292c9158164dff074e32c699b64891cb4b","appveyor.yml":"c61473b8c780ad2626282ce2b2ba0ef278082b6afe151a62ff419f33eaf90221","src/lib.rs":"75b44acfc9627b821cd725649db07693a43b2e44b2fac19b79354c6d950c4038","src/macros.rs":"3953610da3ee2dc393262b753f2406d1864a1cbd74d2bd20d279e09aabfe7131","tests/filters.rs":"cc61ed41a6cd77e5aef91cc8c76216b492d8de34f00635254f3835a3d964ce22"},"package":"880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b"}
|
|
@ -0,0 +1,29 @@
|
|||
language: rust
|
||||
sudo: false
|
||||
rust:
|
||||
- stable
|
||||
- beta
|
||||
- nightly
|
||||
before_script:
|
||||
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
|
||||
script:
|
||||
- cargo build --verbose
|
||||
- ([ $TRAVIS_RUST_VERSION != nightly ] || cargo build --verbose --no-default-features)
|
||||
- ([ $TRAVIS_RUST_VERSION != nightly ] || cargo build --verbose --features nightly)
|
||||
- cargo test --verbose
|
||||
- ([ $TRAVIS_RUST_VERSION != nightly ] || cargo test --verbose --no-default-features)
|
||||
- cargo test --verbose --manifest-path env/Cargo.toml
|
||||
- cargo test --verbose --manifest-path env/Cargo.toml --no-default-features
|
||||
- cargo run --verbose --manifest-path tests/max_level_features/Cargo.toml
|
||||
- cargo run --verbose --manifest-path tests/max_level_features/Cargo.toml --release
|
||||
- ([ $TRAVIS_RUST_VERSION != nightly ] || cargo doc --no-deps --features nightly)
|
||||
- CARGO_TARGET_DIR=target cargo doc --no-deps --manifest-path env/Cargo.toml
|
||||
after_success:
|
||||
- travis-cargo --only nightly doc-upload
|
||||
env:
|
||||
global:
|
||||
secure: "VPHgnszydMudYTY8cthHj/Dmxqp7OmTiu4Sa/705Udsx+tYblTv+8WdThkClo3C/asStVcxlaRWAp91UX32/k4SfkPz17XId3Wadyt03r73ANm6ZOWY+qty+3/LINm54kuTxYUDDTbD6NaFNPFQLIE0xCpJeiXUQTlaMk6z0W3M="
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
|
@ -0,0 +1,49 @@
|
|||
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g. crates.io) dependencies
|
||||
#
|
||||
# If you believe there's an error in this file please file an
|
||||
# issue against the rust-lang/cargo repository. If you're
|
||||
# editing this file be aware that the upstream Cargo.toml
|
||||
# will likely look very different (and much more reasonable)
|
||||
|
||||
[package]
|
||||
name = "log"
|
||||
version = "0.3.8"
|
||||
authors = ["The Rust Project Developers"]
|
||||
description = "A lightweight logging facade for Rust\n"
|
||||
homepage = "https://github.com/rust-lang/log"
|
||||
documentation = "https://docs.rs/log"
|
||||
readme = "README.md"
|
||||
categories = ["development-tools::debugging"]
|
||||
license = "MIT/Apache-2.0"
|
||||
repository = "https://github.com/rust-lang/log"
|
||||
|
||||
[[test]]
|
||||
name = "filters"
|
||||
harness = false
|
||||
|
||||
[features]
|
||||
max_level_info = []
|
||||
nightly = []
|
||||
max_level_warn = []
|
||||
release_max_level_debug = []
|
||||
release_max_level_info = []
|
||||
release_max_level_off = []
|
||||
release_max_level_error = []
|
||||
max_level_debug = []
|
||||
release_max_level_warn = []
|
||||
use_std = []
|
||||
max_level_off = []
|
||||
max_level_trace = []
|
||||
release_max_level_trace = []
|
||||
max_level_error = []
|
||||
default = ["use_std"]
|
||||
[badges.appveyor]
|
||||
repository = "alexcrichton/log"
|
||||
|
||||
[badges.travis-ci]
|
||||
repository = "rust-lang-nursery/log"
|
|
@ -0,0 +1,201 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -0,0 +1,25 @@
|
|||
Copyright (c) 2014 The Rust Project Developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,177 @@
|
|||
log
|
||||
===
|
||||
|
||||
A Rust library providing a lightweight logging *facade*.
|
||||
|
||||
[![Build Status](https://travis-ci.org/rust-lang-nursery/log.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/log)
|
||||
[![Build status](https://ci.appveyor.com/api/projects/status/nopdjmmjt45xcrki?svg=true)](https://ci.appveyor.com/project/alexcrichton/log)
|
||||
|
||||
* [`log` documentation](https://doc.rust-lang.org/log)
|
||||
* [`env_logger` documentation](https://doc.rust-lang.org/log/env_logger)
|
||||
|
||||
A logging facade provides a single logging API that abstracts over the actual
|
||||
logging implementation. Libraries can use the logging API provided by this
|
||||
crate, and the consumer of those libraries can choose the logging
|
||||
implementation that is most suitable for its use case.
|
||||
|
||||
## Usage
|
||||
|
||||
## In libraries
|
||||
|
||||
Libraries should link only to the `log` crate, and use the provided macros to
|
||||
log whatever information will be useful to downstream consumers:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
log = "0.3"
|
||||
```
|
||||
|
||||
```rust
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
pub fn shave_the_yak(yak: &Yak) {
|
||||
trace!("Commencing yak shaving");
|
||||
|
||||
loop {
|
||||
match find_a_razor() {
|
||||
Ok(razor) => {
|
||||
info!("Razor located: {}", razor);
|
||||
yak.shave(razor);
|
||||
break;
|
||||
}
|
||||
Err(err) => {
|
||||
warn!("Unable to locate a razor: {}, retrying", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## In executables
|
||||
|
||||
Executables should choose a logger implementation and initialize it early in the
|
||||
runtime of the program. Logger implementations will typically include a
|
||||
function to do this. Any log messages generated before the logger is
|
||||
initialized will be ignored.
|
||||
|
||||
The executable itself may use the `log` crate to log as well.
|
||||
|
||||
The `env_logger` crate provides a logger implementation that mirrors the
|
||||
functionality of the old revision of the `log` crate.
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
log = "0.3"
|
||||
env_logger = "0.3"
|
||||
```
|
||||
|
||||
```rust
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate env_logger;
|
||||
|
||||
fn main() {
|
||||
env_logger::init().unwrap();
|
||||
|
||||
info!("starting up");
|
||||
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
## In tests
|
||||
|
||||
Tests can use the `env_logger` crate to see log messages generated during that test:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
log = "0.3"
|
||||
|
||||
[dev-dependencies]
|
||||
env_logger = "0.3"
|
||||
```
|
||||
|
||||
```rust
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
fn add_one(num: i32) -> i32 {
|
||||
info!("add_one called with {}", num);
|
||||
num + 1
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
extern crate env_logger;
|
||||
|
||||
#[test]
|
||||
fn it_adds_one() {
|
||||
let _ = env_logger::init();
|
||||
info!("can log from the test too");
|
||||
assert_eq!(3, add_one(2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_handles_negative_numbers() {
|
||||
let _ = env_logger::init();
|
||||
info!("logging from another test");
|
||||
assert_eq!(-7, add_one(-8));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Assuming the module under test is called `my_lib`, running the tests with the
|
||||
`RUST_LOG` filtering to info messages from this module looks like:
|
||||
|
||||
```bash
|
||||
$ RUST_LOG=my_lib=info cargo test
|
||||
Running target/debug/my_lib-...
|
||||
|
||||
running 2 tests
|
||||
INFO:my_lib::tests: logging from another test
|
||||
INFO:my_lib: add_one called with -8
|
||||
test tests::it_handles_negative_numbers ... ok
|
||||
INFO:my_lib::tests: can log from the test too
|
||||
INFO:my_lib: add_one called with 2
|
||||
test tests::it_adds_one ... ok
|
||||
|
||||
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured
|
||||
```
|
||||
|
||||
Note that `env_logger::init()` needs to be called in each test in which you
|
||||
want to enable logging. Additionally, the default behavior of tests to
|
||||
run in parallel means that logging output may be interleaved with test output.
|
||||
Either run tests in a single thread by specifying `RUST_TEST_THREADS=1` or by
|
||||
running one test by specifying its name as an argument to the test binaries as
|
||||
directed by the `cargo test` help docs:
|
||||
|
||||
```bash
|
||||
$ RUST_LOG=my_lib=info cargo test it_adds_one
|
||||
Running target/debug/my_lib-...
|
||||
|
||||
running 1 test
|
||||
INFO:my_lib::tests: can log from the test too
|
||||
INFO:my_lib: add_one called with 2
|
||||
test tests::it_adds_one ... ok
|
||||
|
||||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
||||
```
|
||||
|
||||
## Configuring log target
|
||||
|
||||
By default, `env_logger` logs to stderr. If you want to log to stdout instead,
|
||||
you can use the `LogBuilder` to change the log target:
|
||||
|
||||
```rust
|
||||
use std::env;
|
||||
use env_logger::{LogBuilder, LogTarget};
|
||||
|
||||
let mut builder = LogBuilder::new();
|
||||
builder.target(LogTarget::Stdout);
|
||||
if env::var("RUST_LOG").is_ok() {
|
||||
builder.parse(&env::var("RUST_LOG").unwrap());
|
||||
}
|
||||
builder.init().unwrap();
|
||||
```
|
|
@ -0,0 +1,18 @@
|
|||
environment:
|
||||
matrix:
|
||||
- TARGET: x86_64-pc-windows-msvc
|
||||
- TARGET: i686-pc-windows-msvc
|
||||
- TARGET: i686-pc-windows-gnu
|
||||
install:
|
||||
- ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe"
|
||||
- rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
|
||||
- SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin
|
||||
- SET PATH=%PATH%;C:\MinGW\bin
|
||||
- rustc -V
|
||||
- cargo -V
|
||||
|
||||
build: false
|
||||
|
||||
test_script:
|
||||
- cargo test --verbose
|
||||
- cargo test --manifest-path env/Cargo.toml
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,243 @@
|
|||
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
/// The standard logging macro.
|
||||
///
|
||||
/// This macro will generically log with the specified `LogLevel` and `format!`
|
||||
/// based argument list.
|
||||
///
|
||||
/// The `max_level_*` features can be used to statically disable logging at
|
||||
/// various levels.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[macro_use]
|
||||
/// # extern crate log;
|
||||
/// use log::LogLevel;
|
||||
///
|
||||
/// # fn main() {
|
||||
/// let data = (42, "Forty-two");
|
||||
/// let private_data = "private";
|
||||
///
|
||||
/// log!(LogLevel::Error, "Received errors: {}, {}", data.0, data.1);
|
||||
/// log!(target: "app_events", LogLevel::Warn, "App warning: {}, {}, {}",
|
||||
/// data.0, data.1, private_data);
|
||||
/// # }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! log {
|
||||
(target: $target:expr, $lvl:expr, $($arg:tt)+) => ({
|
||||
static _LOC: $crate::LogLocation = $crate::LogLocation {
|
||||
__line: line!(),
|
||||
__file: file!(),
|
||||
__module_path: module_path!(),
|
||||
};
|
||||
let lvl = $lvl;
|
||||
if lvl <= $crate::__static_max_level() && lvl <= $crate::max_log_level() {
|
||||
$crate::__log(lvl, $target, &_LOC, format_args!($($arg)+))
|
||||
}
|
||||
});
|
||||
($lvl:expr, $($arg:tt)+) => (log!(target: module_path!(), $lvl, $($arg)+))
|
||||
}
|
||||
|
||||
/// Logs a message at the error level.
|
||||
///
|
||||
/// Logging at this level is disabled if the `max_level_off` feature is present.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[macro_use]
|
||||
/// # extern crate log;
|
||||
/// # fn main() {
|
||||
/// let (err_info, port) = ("No connection", 22);
|
||||
///
|
||||
/// error!("Error: {} on port {}", err_info, port);
|
||||
/// error!(target: "app_events", "App Error: {}, Port: {}", err_info, 22);
|
||||
/// # }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! error {
|
||||
(target: $target:expr, $($arg:tt)*) => (
|
||||
log!(target: $target, $crate::LogLevel::Error, $($arg)*);
|
||||
);
|
||||
($($arg:tt)*) => (
|
||||
log!($crate::LogLevel::Error, $($arg)*);
|
||||
)
|
||||
}
|
||||
|
||||
/// Logs a message at the warn level.
|
||||
///
|
||||
/// Logging at this level is disabled if any of the following features are
|
||||
/// present: `max_level_off` or `max_level_error`.
|
||||
///
|
||||
/// When building in release mode (i.e., without the `debug_assertions` option),
|
||||
/// logging at this level is also disabled if any of the following features are
|
||||
/// present: `release_max_level_off` or `max_level_error`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[macro_use]
|
||||
/// # extern crate log;
|
||||
/// # fn main() {
|
||||
/// let warn_description = "Invalid Input";
|
||||
///
|
||||
/// warn!("Warning! {}!", warn_description);
|
||||
/// warn!(target: "input_events", "App received warning: {}", warn_description);
|
||||
/// # }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! warn {
|
||||
(target: $target:expr, $($arg:tt)*) => (
|
||||
log!(target: $target, $crate::LogLevel::Warn, $($arg)*);
|
||||
);
|
||||
($($arg:tt)*) => (
|
||||
log!($crate::LogLevel::Warn, $($arg)*);
|
||||
)
|
||||
}
|
||||
|
||||
/// Logs a message at the info level.
|
||||
///
|
||||
/// Logging at this level is disabled if any of the following features are
|
||||
/// present: `max_level_off`, `max_level_error`, or `max_level_warn`.
|
||||
///
|
||||
/// When building in release mode (i.e., without the `debug_assertions` option),
|
||||
/// logging at this level is also disabled if any of the following features are
|
||||
/// present: `release_max_level_off`, `release_max_level_error`, or
|
||||
/// `release_max_level_warn`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[macro_use]
|
||||
/// # extern crate log;
|
||||
/// # fn main() {
|
||||
/// # struct Connection { port: u32, speed: f32 }
|
||||
/// let conn_info = Connection { port: 40, speed: 3.20 };
|
||||
///
|
||||
/// info!("Connected to port {} at {} Mb/s", conn_info.port, conn_info.speed);
|
||||
/// info!(target: "connection_events", "Successfull connection, port: {}, speed: {}",
|
||||
/// conn_info.port, conn_info.speed);
|
||||
/// # }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! info {
|
||||
(target: $target:expr, $($arg:tt)*) => (
|
||||
log!(target: $target, $crate::LogLevel::Info, $($arg)*);
|
||||
);
|
||||
($($arg:tt)*) => (
|
||||
log!($crate::LogLevel::Info, $($arg)*);
|
||||
)
|
||||
}
|
||||
|
||||
/// Logs a message at the debug level.
|
||||
///
|
||||
/// Logging at this level is disabled if any of the following features are
|
||||
/// present: `max_level_off`, `max_level_error`, `max_level_warn`, or
|
||||
/// `max_level_info`.
|
||||
///
|
||||
/// When building in release mode (i.e., without the `debug_assertions` option),
|
||||
/// logging at this level is also disabled if any of the following features are
|
||||
/// present: `release_max_level_off`, `release_max_level_error`,
|
||||
/// `release_max_level_warn`, or `release_max_level_info`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[macro_use]
|
||||
/// # extern crate log;
|
||||
/// # fn main() {
|
||||
/// # struct Position { x: f32, y: f32 }
|
||||
/// let pos = Position { x: 3.234, y: -1.223 };
|
||||
///
|
||||
/// debug!("New position: x: {}, y: {}", pos.x, pos.y);
|
||||
/// debug!(target: "app_events", "New position: x: {}, y: {}", pos.x, pos.y);
|
||||
/// # }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! debug {
|
||||
(target: $target:expr, $($arg:tt)*) => (
|
||||
log!(target: $target, $crate::LogLevel::Debug, $($arg)*);
|
||||
);
|
||||
($($arg:tt)*) => (
|
||||
log!($crate::LogLevel::Debug, $($arg)*);
|
||||
)
|
||||
}
|
||||
|
||||
/// Logs a message at the trace level.
|
||||
///
|
||||
/// Logging at this level is disabled if any of the following features are
|
||||
/// present: `max_level_off`, `max_level_error`, `max_level_warn`,
|
||||
/// `max_level_info`, or `max_level_debug`.
|
||||
///
|
||||
/// When building in release mode (i.e., without the `debug_assertions` option),
|
||||
/// logging at this level is also disabled if any of the following features are
|
||||
/// present: `release_max_level_off`, `release_max_level_error`,
|
||||
/// `release_max_level_warn`, `release_max_level_info`, or
|
||||
/// `release_max_level_debug`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[macro_use]
|
||||
/// # extern crate log;
|
||||
/// # fn main() {
|
||||
/// # struct Position { x: f32, y: f32 }
|
||||
/// let pos = Position { x: 3.234, y: -1.223 };
|
||||
///
|
||||
/// trace!("Position is: x: {}, y: {}", pos.x, pos.y);
|
||||
/// trace!(target: "app_events", "x is {} and y is {}",
|
||||
/// if pos.x >= 0.0 { "positive" } else { "negative" },
|
||||
/// if pos.y >= 0.0 { "positive" } else { "negative" });
|
||||
/// # }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! trace {
|
||||
(target: $target:expr, $($arg:tt)*) => (
|
||||
log!(target: $target, $crate::LogLevel::Trace, $($arg)*);
|
||||
);
|
||||
($($arg:tt)*) => (
|
||||
log!($crate::LogLevel::Trace, $($arg)*);
|
||||
)
|
||||
}
|
||||
|
||||
/// Determines if a message logged at the specified level in that module will
|
||||
/// be logged.
|
||||
///
|
||||
/// This can be used to avoid expensive computation of log message arguments if
|
||||
/// the message would be ignored anyway.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[macro_use]
|
||||
/// # extern crate log;
|
||||
/// use log::LogLevel::Debug;
|
||||
///
|
||||
/// # fn foo() {
|
||||
/// if log_enabled!(Debug) {
|
||||
/// let data = expensive_call();
|
||||
/// debug!("expensive debug data: {} {}", data.x, data.y);
|
||||
/// }
|
||||
/// # }
|
||||
/// # struct Data { x: u32, y: u32 }
|
||||
/// # fn expensive_call() -> Data { Data { x: 0, y: 0 } }
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! log_enabled {
|
||||
(target: $target:expr, $lvl:expr) => ({
|
||||
let lvl = $lvl;
|
||||
lvl <= $crate::__static_max_level() && lvl <= $crate::max_log_level() &&
|
||||
$crate::__enabled(lvl, $target)
|
||||
});
|
||||
($lvl:expr) => (log_enabled!(target: module_path!(), $lvl))
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
#[macro_use] extern crate log;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
use log::{LogLevel, LogLevelFilter, Log, LogRecord, LogMetadata};
|
||||
use log::MaxLogLevelFilter;
|
||||
|
||||
#[cfg(feature = "use_std")]
|
||||
use log::set_logger;
|
||||
#[cfg(not(feature = "use_std"))]
|
||||
fn set_logger<M>(make_logger: M) -> Result<(), log::SetLoggerError>
|
||||
where M: FnOnce(MaxLogLevelFilter) -> Box<Log> {
|
||||
unsafe {
|
||||
log::set_logger_raw(|x| std::mem::transmute(make_logger(x)))
|
||||
}
|
||||
}
|
||||
|
||||
struct State {
|
||||
last_log: Mutex<Option<LogLevel>>,
|
||||
filter: MaxLogLevelFilter,
|
||||
}
|
||||
|
||||
struct Logger(Arc<State>);
|
||||
|
||||
impl Log for Logger {
|
||||
fn enabled(&self, _: &LogMetadata) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn log(&self, record: &LogRecord) {
|
||||
*self.0.last_log.lock().unwrap() = Some(record.level());
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut a = None;
|
||||
set_logger(|max| {
|
||||
let me = Arc::new(State {
|
||||
last_log: Mutex::new(None),
|
||||
filter: max,
|
||||
});
|
||||
a = Some(me.clone());
|
||||
Box::new(Logger(me))
|
||||
}).unwrap();
|
||||
let a = a.unwrap();
|
||||
|
||||
test(&a, LogLevelFilter::Off);
|
||||
test(&a, LogLevelFilter::Error);
|
||||
test(&a, LogLevelFilter::Warn);
|
||||
test(&a, LogLevelFilter::Info);
|
||||
test(&a, LogLevelFilter::Debug);
|
||||
test(&a, LogLevelFilter::Trace);
|
||||
}
|
||||
|
||||
fn test(a: &State, filter: LogLevelFilter) {
|
||||
a.filter.set(filter);
|
||||
error!("");
|
||||
last(&a, t(LogLevel::Error, filter));
|
||||
warn!("");
|
||||
last(&a, t(LogLevel::Warn, filter));
|
||||
info!("");
|
||||
last(&a, t(LogLevel::Info, filter));
|
||||
debug!("");
|
||||
last(&a, t(LogLevel::Debug, filter));
|
||||
trace!("");
|
||||
last(&a, t(LogLevel::Trace, filter));
|
||||
|
||||
fn t(lvl: LogLevel, filter: LogLevelFilter) -> Option<LogLevel> {
|
||||
if lvl <= filter {Some(lvl)} else {None}
|
||||
}
|
||||
}
|
||||
|
||||
fn last(state: &State, expected: Option<LogLevel>) {
|
||||
let mut lvl = state.last_log.lock().unwrap();
|
||||
assert_eq!(*lvl, expected);
|
||||
*lvl = None;
|
||||
}
|
|
@ -1 +1 @@
|
|||
{"files":{".travis.yml":"985cf95c79f32c65766927fd6ef5079f8c14f235ddb4213e6410d90a86a95811","Cargo.toml":"0a4a756f7ef47f5dfa221a173b21f9ec496b448aafcd9bde08d9d16935b55007","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"aa8356455efcc3d49f66e7fa394eac292c9158164dff074e32c699b64891cb4b","appveyor.yml":"c61473b8c780ad2626282ce2b2ba0ef278082b6afe151a62ff419f33eaf90221","src/lib.rs":"75b44acfc9627b821cd725649db07693a43b2e44b2fac19b79354c6d950c4038","src/macros.rs":"3953610da3ee2dc393262b753f2406d1864a1cbd74d2bd20d279e09aabfe7131","tests/filters.rs":"cc61ed41a6cd77e5aef91cc8c76216b492d8de34f00635254f3835a3d964ce22"},"package":"880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b"}
|
||||
{"files":{".travis.yml":"8e95f3543ff36e1fd0e2e2fcc98b31e20dcc19d220f3d7d19bfb9aeb61030823","CHANGELOG.md":"cdfe104547fca9d80b95cff2c6ef5af7cdcd0a17886ec3722c157a598abec018","Cargo.toml":"ba13b382a64b910241ce4fc2ac4f45dd3a8f404f762f07958004a41de1cb55df","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"95873097578066ef6a0cc395f1aad5596762570ba1476757643fb319e3892481","appveyor.yml":"d5376a881aef6dc3bed6a6b51f1f1c3801b88fc77a12895f6953190256e965bc","src/lib.rs":"4ffa677655636a6c111026d318c92bb53bd91988e601fcdcdbe1f43b1997b8fd","src/macros.rs":"064c96e154b58b61b8a4f11cab9c0664dd171010f578af438fad0dc1d796ac5c","src/serde.rs":"7617ffa21dde363a06389f8e26661f35550c1a01ff142f81275e95f42b79c854","tests/filters.rs":"6aee024d4594b4fde772e35c5d3318e5aa5d9aa4eaeafb04e4c7c922be4ac837"},"package":"89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2"}
|
|
@ -1,28 +1,19 @@
|
|||
language: rust
|
||||
sudo: false
|
||||
rust:
|
||||
- 1.16.0
|
||||
- stable
|
||||
- beta
|
||||
- nightly
|
||||
before_script:
|
||||
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
|
||||
script:
|
||||
- cargo build --verbose
|
||||
- ([ $TRAVIS_RUST_VERSION != nightly ] || cargo build --verbose --no-default-features)
|
||||
- ([ $TRAVIS_RUST_VERSION != nightly ] || cargo build --verbose --features nightly)
|
||||
- cargo build --verbose --features serde
|
||||
- cargo build --verbose --features std
|
||||
- cargo test --verbose
|
||||
- ([ $TRAVIS_RUST_VERSION != nightly ] || cargo test --verbose --no-default-features)
|
||||
- cargo test --verbose --manifest-path env/Cargo.toml
|
||||
- cargo test --verbose --manifest-path env/Cargo.toml --no-default-features
|
||||
- cargo test --verbose --features serde
|
||||
- cargo test --verbose --features std
|
||||
- cargo run --verbose --manifest-path tests/max_level_features/Cargo.toml
|
||||
- cargo run --verbose --manifest-path tests/max_level_features/Cargo.toml --release
|
||||
- ([ $TRAVIS_RUST_VERSION != nightly ] || cargo doc --no-deps --features nightly)
|
||||
- CARGO_TARGET_DIR=target cargo doc --no-deps --manifest-path env/Cargo.toml
|
||||
after_success:
|
||||
- travis-cargo --only nightly doc-upload
|
||||
env:
|
||||
global:
|
||||
secure: "VPHgnszydMudYTY8cthHj/Dmxqp7OmTiu4Sa/705Udsx+tYblTv+8WdThkClo3C/asStVcxlaRWAp91UX32/k4SfkPz17XId3Wadyt03r73ANm6ZOWY+qty+3/LINm54kuTxYUDDTbD6NaFNPFQLIE0xCpJeiXUQTlaMk6z0W3M="
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
# Change Log
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.4.1] - 2017-12-30
|
||||
|
||||
### Fixed
|
||||
|
||||
* Some doc links were fixed.
|
||||
|
||||
## [0.4.0] - 2017-12-24
|
||||
|
||||
The changes in this release include cleanup of some obscure functionality and a more robust public
|
||||
API designed to support bridges to other logging systems, and provide more flexibility to new
|
||||
features in the future.
|
||||
|
||||
### Compatibility
|
||||
|
||||
Vast portions of the Rust ecosystem use the 0.3.x release series of log, and we don't want to force
|
||||
the community to go through the pain of upgrading every crate to 0.4.x at the exact same time. Along
|
||||
with 0.4.0, we've published a new 0.3.9 release which acts as a "shim" over 0.4.0. This will allow
|
||||
crates using either version to coexist without losing messages from one side or the other.
|
||||
|
||||
There is one caveat - a log message generated by a crate using 0.4.x but consumed by a logging
|
||||
implementation using 0.3.x will not have a file name or module path. Applications affected by this
|
||||
can upgrade their logging implementations to one using 0.4.x to avoid losing this information. The
|
||||
other direction does not lose any information, fortunately!
|
||||
|
||||
**TL;DR** Libraries should feel comfortable upgrading to 0.4.0 without treating that as a breaking
|
||||
change. Applications may need to update their logging implementation (e.g. env-logger) to a newer
|
||||
version using log 0.4.x to avoid losing module and file information.
|
||||
|
||||
### New
|
||||
|
||||
* The crate is now `no_std` by default.
|
||||
* `Level` and `LevelFilter` now implement `Serialize` and `Deserialize` when the `serde` feature is
|
||||
enabled.
|
||||
* The `Record` and `Metadata` types can now be constructed by third-party code via a builder API.
|
||||
* The `logger` free function returns a reference to the logger implementation. This, along with the
|
||||
ability to construct `Record`s, makes it possible to bridge from another logging framework to
|
||||
this one without digging into the private internals of the crate. The standard `error!` `warn!`,
|
||||
etc, macros now exclusively use the public API of the crate rather than "secret" internal APIs.
|
||||
* `Log::flush` has been added to allow crates to tell the logging implementation to ensure that all
|
||||
"in flight" log events have been persisted. This can be used, for example, just before an
|
||||
application exits to ensure that asynchronous log sinks finish their work.
|
||||
|
||||
### Removed
|
||||
|
||||
* The `shutdown` and `shutdown_raw` functions have been removed. Supporting shutdown significantly
|
||||
complicated the implementation and imposed a performance cost on each logging operation.
|
||||
* The `log_panics` function and its associated `nightly` Cargo feature have been removed. Use the
|
||||
[log-panics](https://crates.io/crates/log-panics) instead.
|
||||
|
||||
### Changed
|
||||
|
||||
* The `Log` prefix has been removed from type names. For example, `LogLevelFilter` is now
|
||||
`LevelFilter`, and `LogRecord` is now `Record`.
|
||||
* The `MaxLogLevelFilter` object has been removed in favor of a `set_max_level` free function.
|
||||
* The `set_logger` free functions have been restructured. The logger is now directly passed to the
|
||||
functions rather than a closure which returns the logger. `set_logger` now takes a `&'static
|
||||
Log` and is usable in `no_std` contexts in place of the old `set_logger_raw`. `set_boxed_logger`
|
||||
is a convenience function which takes a `Box<Log>` but otherwise acts like `set_logger`. It
|
||||
requires the `std` feature.
|
||||
* The `file` and `module_path` values in `Record` no longer have the `'static` lifetime to support
|
||||
integration with other logging frameworks that don't provide a `'static` lifetime for the
|
||||
equivalent values.
|
||||
* The `file`, `line`, and `module_path` values in `Record` are now `Option`s to support integration
|
||||
with other logging frameworks that don't provide those values.
|
||||
|
||||
### In the Future
|
||||
|
||||
* We're looking to add support for *structured* logging - the inclusion of extra key-value pairs of
|
||||
information in a log event in addition to the normal string message. This should be able to be
|
||||
added in a backwards compatible manner to the 0.4.x series when the design is worked out.
|
||||
|
||||
## Older
|
||||
|
||||
Look at the [release tags] for information about older releases.
|
||||
|
||||
[Unreleased]: https://github.com/rust-lang-nursery/log/compare/0.4.1...HEAD
|
||||
[0.4.1]: https://github.com/rust-lang-nursery/log/compare/0.4.0...0.4.1
|
||||
[0.4.0]: https://github.com/rust-lang-nursery/log/compare/0.3.8...0.4.0
|
||||
[release tags]: https://github.com/rust-lang-nursery/log/releases
|
|
@ -12,36 +12,46 @@
|
|||
|
||||
[package]
|
||||
name = "log"
|
||||
version = "0.3.8"
|
||||
version = "0.4.1"
|
||||
authors = ["The Rust Project Developers"]
|
||||
description = "A lightweight logging facade for Rust\n"
|
||||
homepage = "https://github.com/rust-lang/log"
|
||||
documentation = "https://docs.rs/log"
|
||||
readme = "README.md"
|
||||
keywords = ["logging"]
|
||||
categories = ["development-tools::debugging"]
|
||||
license = "MIT/Apache-2.0"
|
||||
repository = "https://github.com/rust-lang/log"
|
||||
[package.metadata.docs.rs]
|
||||
features = ["std", "serde"]
|
||||
|
||||
[[test]]
|
||||
name = "filters"
|
||||
harness = false
|
||||
[dependencies.cfg-if]
|
||||
version = "0.1.2"
|
||||
|
||||
[dependencies.serde]
|
||||
version = "1.0"
|
||||
optional = true
|
||||
default-features = false
|
||||
[dev-dependencies.serde_test]
|
||||
version = "1.0"
|
||||
|
||||
[features]
|
||||
max_level_info = []
|
||||
nightly = []
|
||||
max_level_warn = []
|
||||
release_max_level_debug = []
|
||||
release_max_level_info = []
|
||||
release_max_level_off = []
|
||||
release_max_level_error = []
|
||||
max_level_debug = []
|
||||
release_max_level_warn = []
|
||||
use_std = []
|
||||
max_level_error = []
|
||||
max_level_info = []
|
||||
max_level_off = []
|
||||
max_level_trace = []
|
||||
max_level_warn = []
|
||||
release_max_level_debug = []
|
||||
release_max_level_error = []
|
||||
release_max_level_info = []
|
||||
release_max_level_off = []
|
||||
release_max_level_trace = []
|
||||
max_level_error = []
|
||||
default = ["use_std"]
|
||||
release_max_level_warn = []
|
||||
std = []
|
||||
[badges.appveyor]
|
||||
repository = "alexcrichton/log"
|
||||
|
||||
|
|
|
@ -6,8 +6,7 @@ A Rust library providing a lightweight logging *facade*.
|
|||
[![Build Status](https://travis-ci.org/rust-lang-nursery/log.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/log)
|
||||
[![Build status](https://ci.appveyor.com/api/projects/status/nopdjmmjt45xcrki?svg=true)](https://ci.appveyor.com/project/alexcrichton/log)
|
||||
|
||||
* [`log` documentation](https://doc.rust-lang.org/log)
|
||||
* [`env_logger` documentation](https://doc.rust-lang.org/log/env_logger)
|
||||
* [`log` documentation](https://docs.rs/log)
|
||||
|
||||
A logging facade provides a single logging API that abstracts over the actual
|
||||
logging implementation. Libraries can use the logging API provided by this
|
||||
|
@ -23,7 +22,7 @@ log whatever information will be useful to downstream consumers:
|
|||
|
||||
```toml
|
||||
[dependencies]
|
||||
log = "0.3"
|
||||
log = "0.4"
|
||||
```
|
||||
|
||||
```rust
|
||||
|
@ -50,128 +49,26 @@ pub fn shave_the_yak(yak: &Yak) {
|
|||
|
||||
## In executables
|
||||
|
||||
In order to produce log output executables have to use a logger implementation compatible with the facade.
|
||||
There are many available implementations to chose from, here are some of the most popular ones:
|
||||
|
||||
* Simple minimal loggers:
|
||||
* [`env_logger`](https://docs.rs/env_logger/*/env_logger/)
|
||||
* [`simple_logger`](https://github.com/borntyping/rust-simple_logger)
|
||||
* [`simplelog`](https://github.com/drakulix/simplelog.rs)
|
||||
* [`pretty_env_logger`](https://docs.rs/pretty_env_logger/*/pretty_env_logger/)
|
||||
* [`stderrlog`](https://docs.rs/stderrlog/*/stderrlog/)
|
||||
* [`flexi_logger`](https://docs.rs/flexi_logger/*/flexi_logger/)
|
||||
* Complex configurable frameworks:
|
||||
* [`log4rs`](https://docs.rs/log4rs/*/log4rs/)
|
||||
* [`fern`](https://docs.rs/fern/*/fern/)
|
||||
* Adaptors for other facilities:
|
||||
* [`syslog`](https://docs.rs/syslog/*/syslog/)
|
||||
* [`slog-stdlog`](https://docs.rs/slog-stdlog/*/slog_stdlog/)
|
||||
|
||||
Executables should choose a logger implementation and initialize it early in the
|
||||
runtime of the program. Logger implementations will typically include a
|
||||
function to do this. Any log messages generated before the logger is
|
||||
initialized will be ignored.
|
||||
|
||||
The executable itself may use the `log` crate to log as well.
|
||||
|
||||
The `env_logger` crate provides a logger implementation that mirrors the
|
||||
functionality of the old revision of the `log` crate.
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
log = "0.3"
|
||||
env_logger = "0.3"
|
||||
```
|
||||
|
||||
```rust
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate env_logger;
|
||||
|
||||
fn main() {
|
||||
env_logger::init().unwrap();
|
||||
|
||||
info!("starting up");
|
||||
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
## In tests
|
||||
|
||||
Tests can use the `env_logger` crate to see log messages generated during that test:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
log = "0.3"
|
||||
|
||||
[dev-dependencies]
|
||||
env_logger = "0.3"
|
||||
```
|
||||
|
||||
```rust
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
fn add_one(num: i32) -> i32 {
|
||||
info!("add_one called with {}", num);
|
||||
num + 1
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
extern crate env_logger;
|
||||
|
||||
#[test]
|
||||
fn it_adds_one() {
|
||||
let _ = env_logger::init();
|
||||
info!("can log from the test too");
|
||||
assert_eq!(3, add_one(2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_handles_negative_numbers() {
|
||||
let _ = env_logger::init();
|
||||
info!("logging from another test");
|
||||
assert_eq!(-7, add_one(-8));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Assuming the module under test is called `my_lib`, running the tests with the
|
||||
`RUST_LOG` filtering to info messages from this module looks like:
|
||||
|
||||
```bash
|
||||
$ RUST_LOG=my_lib=info cargo test
|
||||
Running target/debug/my_lib-...
|
||||
|
||||
running 2 tests
|
||||
INFO:my_lib::tests: logging from another test
|
||||
INFO:my_lib: add_one called with -8
|
||||
test tests::it_handles_negative_numbers ... ok
|
||||
INFO:my_lib::tests: can log from the test too
|
||||
INFO:my_lib: add_one called with 2
|
||||
test tests::it_adds_one ... ok
|
||||
|
||||
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured
|
||||
```
|
||||
|
||||
Note that `env_logger::init()` needs to be called in each test in which you
|
||||
want to enable logging. Additionally, the default behavior of tests to
|
||||
run in parallel means that logging output may be interleaved with test output.
|
||||
Either run tests in a single thread by specifying `RUST_TEST_THREADS=1` or by
|
||||
running one test by specifying its name as an argument to the test binaries as
|
||||
directed by the `cargo test` help docs:
|
||||
|
||||
```bash
|
||||
$ RUST_LOG=my_lib=info cargo test it_adds_one
|
||||
Running target/debug/my_lib-...
|
||||
|
||||
running 1 test
|
||||
INFO:my_lib::tests: can log from the test too
|
||||
INFO:my_lib: add_one called with 2
|
||||
test tests::it_adds_one ... ok
|
||||
|
||||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
||||
```
|
||||
|
||||
## Configuring log target
|
||||
|
||||
By default, `env_logger` logs to stderr. If you want to log to stdout instead,
|
||||
you can use the `LogBuilder` to change the log target:
|
||||
|
||||
```rust
|
||||
use std::env;
|
||||
use env_logger::{LogBuilder, LogTarget};
|
||||
|
||||
let mut builder = LogBuilder::new();
|
||||
builder.target(LogTarget::Stdout);
|
||||
if env::var("RUST_LOG").is_ok() {
|
||||
builder.parse(&env::var("RUST_LOG").unwrap());
|
||||
}
|
||||
builder.init().unwrap();
|
||||
```
|
||||
|
|
|
@ -15,4 +15,5 @@ build: false
|
|||
|
||||
test_script:
|
||||
- cargo test --verbose
|
||||
- cargo test --manifest-path env/Cargo.toml
|
||||
- cargo test --verbose --features serde
|
||||
- cargo test --verbose --features std
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -7,41 +7,44 @@
|
|||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
/// The standard logging macro.
|
||||
///
|
||||
/// This macro will generically log with the specified `LogLevel` and `format!`
|
||||
/// This macro will generically log with the specified `Level` and `format!`
|
||||
/// based argument list.
|
||||
///
|
||||
/// The `max_level_*` features can be used to statically disable logging at
|
||||
/// various levels.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[macro_use]
|
||||
/// # extern crate log;
|
||||
/// use log::LogLevel;
|
||||
/// use log::Level;
|
||||
///
|
||||
/// # fn main() {
|
||||
/// let data = (42, "Forty-two");
|
||||
/// let private_data = "private";
|
||||
///
|
||||
/// log!(LogLevel::Error, "Received errors: {}, {}", data.0, data.1);
|
||||
/// log!(target: "app_events", LogLevel::Warn, "App warning: {}, {}, {}",
|
||||
/// log!(Level::Error, "Received errors: {}, {}", data.0, data.1);
|
||||
/// log!(target: "app_events", Level::Warn, "App warning: {}, {}, {}",
|
||||
/// data.0, data.1, private_data);
|
||||
/// # }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! log {
|
||||
(target: $target:expr, $lvl:expr, $($arg:tt)+) => ({
|
||||
static _LOC: $crate::LogLocation = $crate::LogLocation {
|
||||
__line: line!(),
|
||||
__file: file!(),
|
||||
__module_path: module_path!(),
|
||||
};
|
||||
let lvl = $lvl;
|
||||
if lvl <= $crate::__static_max_level() && lvl <= $crate::max_log_level() {
|
||||
$crate::__log(lvl, $target, &_LOC, format_args!($($arg)+))
|
||||
if lvl <= $crate::STATIC_MAX_LEVEL && lvl <= $crate::max_level() {
|
||||
$crate::Log::log(
|
||||
$crate::logger(),
|
||||
&$crate::RecordBuilder::new()
|
||||
.args(format_args!($($arg)+))
|
||||
.level(lvl)
|
||||
.target($target)
|
||||
.module_path(Some(module_path!()))
|
||||
.file(Some(file!()))
|
||||
.line(Some(line!()))
|
||||
.build()
|
||||
)
|
||||
}
|
||||
});
|
||||
($lvl:expr, $($arg:tt)+) => (log!(target: module_path!(), $lvl, $($arg)+))
|
||||
|
@ -49,8 +52,6 @@ macro_rules! log {
|
|||
|
||||
/// Logs a message at the error level.
|
||||
///
|
||||
/// Logging at this level is disabled if the `max_level_off` feature is present.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
|
@ -66,22 +67,15 @@ macro_rules! log {
|
|||
#[macro_export]
|
||||
macro_rules! error {
|
||||
(target: $target:expr, $($arg:tt)*) => (
|
||||
log!(target: $target, $crate::LogLevel::Error, $($arg)*);
|
||||
log!(target: $target, $crate::Level::Error, $($arg)*);
|
||||
);
|
||||
($($arg:tt)*) => (
|
||||
log!($crate::LogLevel::Error, $($arg)*);
|
||||
log!($crate::Level::Error, $($arg)*);
|
||||
)
|
||||
}
|
||||
|
||||
/// Logs a message at the warn level.
|
||||
///
|
||||
/// Logging at this level is disabled if any of the following features are
|
||||
/// present: `max_level_off` or `max_level_error`.
|
||||
///
|
||||
/// When building in release mode (i.e., without the `debug_assertions` option),
|
||||
/// logging at this level is also disabled if any of the following features are
|
||||
/// present: `release_max_level_off` or `max_level_error`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
|
@ -97,23 +91,15 @@ macro_rules! error {
|
|||
#[macro_export]
|
||||
macro_rules! warn {
|
||||
(target: $target:expr, $($arg:tt)*) => (
|
||||
log!(target: $target, $crate::LogLevel::Warn, $($arg)*);
|
||||
log!(target: $target, $crate::Level::Warn, $($arg)*);
|
||||
);
|
||||
($($arg:tt)*) => (
|
||||
log!($crate::LogLevel::Warn, $($arg)*);
|
||||
log!($crate::Level::Warn, $($arg)*);
|
||||
)
|
||||
}
|
||||
|
||||
/// Logs a message at the info level.
|
||||
///
|
||||
/// Logging at this level is disabled if any of the following features are
|
||||
/// present: `max_level_off`, `max_level_error`, or `max_level_warn`.
|
||||
///
|
||||
/// When building in release mode (i.e., without the `debug_assertions` option),
|
||||
/// logging at this level is also disabled if any of the following features are
|
||||
/// present: `release_max_level_off`, `release_max_level_error`, or
|
||||
/// `release_max_level_warn`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
|
@ -131,24 +117,15 @@ macro_rules! warn {
|
|||
#[macro_export]
|
||||
macro_rules! info {
|
||||
(target: $target:expr, $($arg:tt)*) => (
|
||||
log!(target: $target, $crate::LogLevel::Info, $($arg)*);
|
||||
log!(target: $target, $crate::Level::Info, $($arg)*);
|
||||
);
|
||||
($($arg:tt)*) => (
|
||||
log!($crate::LogLevel::Info, $($arg)*);
|
||||
log!($crate::Level::Info, $($arg)*);
|
||||
)
|
||||
}
|
||||
|
||||
/// Logs a message at the debug level.
|
||||
///
|
||||
/// Logging at this level is disabled if any of the following features are
|
||||
/// present: `max_level_off`, `max_level_error`, `max_level_warn`, or
|
||||
/// `max_level_info`.
|
||||
///
|
||||
/// When building in release mode (i.e., without the `debug_assertions` option),
|
||||
/// logging at this level is also disabled if any of the following features are
|
||||
/// present: `release_max_level_off`, `release_max_level_error`,
|
||||
/// `release_max_level_warn`, or `release_max_level_info`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
|
@ -165,25 +142,15 @@ macro_rules! info {
|
|||
#[macro_export]
|
||||
macro_rules! debug {
|
||||
(target: $target:expr, $($arg:tt)*) => (
|
||||
log!(target: $target, $crate::LogLevel::Debug, $($arg)*);
|
||||
log!(target: $target, $crate::Level::Debug, $($arg)*);
|
||||
);
|
||||
($($arg:tt)*) => (
|
||||
log!($crate::LogLevel::Debug, $($arg)*);
|
||||
log!($crate::Level::Debug, $($arg)*);
|
||||
)
|
||||
}
|
||||
|
||||
/// Logs a message at the trace level.
|
||||
///
|
||||
/// Logging at this level is disabled if any of the following features are
|
||||
/// present: `max_level_off`, `max_level_error`, `max_level_warn`,
|
||||
/// `max_level_info`, or `max_level_debug`.
|
||||
///
|
||||
/// When building in release mode (i.e., without the `debug_assertions` option),
|
||||
/// logging at this level is also disabled if any of the following features are
|
||||
/// present: `release_max_level_off`, `release_max_level_error`,
|
||||
/// `release_max_level_warn`, `release_max_level_info`, or
|
||||
/// `release_max_level_debug`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
|
@ -202,10 +169,10 @@ macro_rules! debug {
|
|||
#[macro_export]
|
||||
macro_rules! trace {
|
||||
(target: $target:expr, $($arg:tt)*) => (
|
||||
log!(target: $target, $crate::LogLevel::Trace, $($arg)*);
|
||||
log!(target: $target, $crate::Level::Trace, $($arg)*);
|
||||
);
|
||||
($($arg:tt)*) => (
|
||||
log!($crate::LogLevel::Trace, $($arg)*);
|
||||
log!($crate::Level::Trace, $($arg)*);
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -220,13 +187,17 @@ macro_rules! trace {
|
|||
/// ```rust
|
||||
/// # #[macro_use]
|
||||
/// # extern crate log;
|
||||
/// use log::LogLevel::Debug;
|
||||
/// use log::Level::Debug;
|
||||
///
|
||||
/// # fn foo() {
|
||||
/// if log_enabled!(Debug) {
|
||||
/// let data = expensive_call();
|
||||
/// debug!("expensive debug data: {} {}", data.x, data.y);
|
||||
/// }
|
||||
/// if log_enabled!(target: "Global", Debug) {
|
||||
/// let data = expensive_call();
|
||||
/// debug!(target: "Global", "expensive debug data: {} {}", data.x, data.y);
|
||||
/// }
|
||||
/// # }
|
||||
/// # struct Data { x: u32, y: u32 }
|
||||
/// # fn expensive_call() -> Data { Data { x: 0, y: 0 } }
|
||||
|
@ -236,8 +207,14 @@ macro_rules! trace {
|
|||
macro_rules! log_enabled {
|
||||
(target: $target:expr, $lvl:expr) => ({
|
||||
let lvl = $lvl;
|
||||
lvl <= $crate::__static_max_level() && lvl <= $crate::max_log_level() &&
|
||||
$crate::__enabled(lvl, $target)
|
||||
lvl <= $crate::STATIC_MAX_LEVEL && lvl <= $crate::max_level() &&
|
||||
$crate::Log::enabled(
|
||||
$crate::logger(),
|
||||
&$crate::MetadataBuilder::new()
|
||||
.level(lvl)
|
||||
.target($target)
|
||||
.build(),
|
||||
)
|
||||
});
|
||||
($lvl:expr) => (log_enabled!(target: module_path!(), $lvl))
|
||||
}
|
||||
|
|
|
@ -0,0 +1,258 @@
|
|||
#![cfg(feature = "serde")]
|
||||
|
||||
extern crate serde;
|
||||
use self::serde::ser::{Serialize, Serializer};
|
||||
use self::serde::de::{Deserialize, DeserializeSeed, Deserializer, Visitor, EnumAccess,
|
||||
VariantAccess, Error};
|
||||
|
||||
use {Level, LevelFilter, LOG_LEVEL_NAMES};
|
||||
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
|
||||
// The Deserialize impls are handwritten to be case insensitive using FromStr.
|
||||
|
||||
impl Serialize for Level {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
match *self {
|
||||
Level::Error => serializer.serialize_unit_variant("Level", 0, "ERROR"),
|
||||
Level::Warn => serializer.serialize_unit_variant("Level", 1, "WARN"),
|
||||
Level::Info => serializer.serialize_unit_variant("Level", 2, "INFO"),
|
||||
Level::Debug => serializer.serialize_unit_variant("Level", 3, "DEBUG"),
|
||||
Level::Trace => serializer.serialize_unit_variant("Level", 4, "TRACE"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for Level {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
struct LevelIdentifier;
|
||||
|
||||
impl<'de> Visitor<'de> for LevelIdentifier {
|
||||
type Value = Level;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
formatter.write_str("log level")
|
||||
}
|
||||
|
||||
fn visit_str<E>(self, s: &str) -> Result<Self::Value, E>
|
||||
where
|
||||
E: Error,
|
||||
{
|
||||
// Case insensitive.
|
||||
FromStr::from_str(s).map_err(|_| Error::unknown_variant(s, &LOG_LEVEL_NAMES[1..]))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> DeserializeSeed<'de> for LevelIdentifier {
|
||||
type Value = Level;
|
||||
|
||||
fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
deserializer.deserialize_identifier(LevelIdentifier)
|
||||
}
|
||||
}
|
||||
|
||||
struct LevelEnum;
|
||||
|
||||
impl<'de> Visitor<'de> for LevelEnum {
|
||||
type Value = Level;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
formatter.write_str("log level")
|
||||
}
|
||||
|
||||
fn visit_enum<A>(self, value: A) -> Result<Self::Value, A::Error>
|
||||
where
|
||||
A: EnumAccess<'de>,
|
||||
{
|
||||
let (level, variant) = value.variant_seed(LevelIdentifier)?;
|
||||
// Every variant is a unit variant.
|
||||
variant.unit_variant()?;
|
||||
Ok(level)
|
||||
}
|
||||
}
|
||||
|
||||
deserializer.deserialize_enum("Level", &LOG_LEVEL_NAMES[1..], LevelEnum)
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for LevelFilter {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
match *self {
|
||||
LevelFilter::Off => serializer.serialize_unit_variant("LevelFilter", 0, "OFF"),
|
||||
LevelFilter::Error => serializer.serialize_unit_variant("LevelFilter", 1, "ERROR"),
|
||||
LevelFilter::Warn => serializer.serialize_unit_variant("LevelFilter", 2, "WARN"),
|
||||
LevelFilter::Info => serializer.serialize_unit_variant("LevelFilter", 3, "INFO"),
|
||||
LevelFilter::Debug => serializer.serialize_unit_variant("LevelFilter", 4, "DEBUG"),
|
||||
LevelFilter::Trace => serializer.serialize_unit_variant("LevelFilter", 5, "TRACE"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for LevelFilter {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
struct LevelFilterIdentifier;
|
||||
|
||||
impl<'de> Visitor<'de> for LevelFilterIdentifier {
|
||||
type Value = LevelFilter;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
formatter.write_str("log level filter")
|
||||
}
|
||||
|
||||
fn visit_str<E>(self, s: &str) -> Result<Self::Value, E>
|
||||
where
|
||||
E: Error,
|
||||
{
|
||||
// Case insensitive.
|
||||
FromStr::from_str(s).map_err(|_| Error::unknown_variant(s, &LOG_LEVEL_NAMES))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> DeserializeSeed<'de> for LevelFilterIdentifier {
|
||||
type Value = LevelFilter;
|
||||
|
||||
fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
deserializer.deserialize_identifier(LevelFilterIdentifier)
|
||||
}
|
||||
}
|
||||
|
||||
struct LevelFilterEnum;
|
||||
|
||||
impl<'de> Visitor<'de> for LevelFilterEnum {
|
||||
type Value = LevelFilter;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
formatter.write_str("log level filter")
|
||||
}
|
||||
|
||||
fn visit_enum<A>(self, value: A) -> Result<Self::Value, A::Error>
|
||||
where
|
||||
A: EnumAccess<'de>,
|
||||
{
|
||||
let (level_filter, variant) = value.variant_seed(LevelFilterIdentifier)?;
|
||||
// Every variant is a unit variant.
|
||||
variant.unit_variant()?;
|
||||
Ok(level_filter)
|
||||
}
|
||||
}
|
||||
|
||||
deserializer.deserialize_enum("LevelFilter", &LOG_LEVEL_NAMES, LevelFilterEnum)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
extern crate serde_test;
|
||||
use self::serde_test::{Token, assert_tokens, assert_de_tokens, assert_de_tokens_error};
|
||||
|
||||
use {Level, LevelFilter};
|
||||
|
||||
fn level_token(variant: &'static str) -> Token {
|
||||
Token::UnitVariant {
|
||||
name: "Level",
|
||||
variant: variant,
|
||||
}
|
||||
}
|
||||
|
||||
fn level_filter_token(variant: &'static str) -> Token {
|
||||
Token::UnitVariant {
|
||||
name: "LevelFilter",
|
||||
variant: variant,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_level_ser_de() {
|
||||
let cases = [
|
||||
(Level::Error, [level_token("ERROR")]),
|
||||
(Level::Warn, [level_token("WARN")]),
|
||||
(Level::Info, [level_token("INFO")]),
|
||||
(Level::Debug, [level_token("DEBUG")]),
|
||||
(Level::Trace, [level_token("TRACE")]),
|
||||
];
|
||||
|
||||
for &(s, expected) in &cases {
|
||||
assert_tokens(&s, &expected);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_level_case_insensitive() {
|
||||
let cases = [
|
||||
(Level::Error, [level_token("error")]),
|
||||
(Level::Warn, [level_token("warn")]),
|
||||
(Level::Info, [level_token("info")]),
|
||||
(Level::Debug, [level_token("debug")]),
|
||||
(Level::Trace, [level_token("trace")]),
|
||||
];
|
||||
|
||||
for &(s, expected) in &cases {
|
||||
assert_de_tokens(&s, &expected);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_level_de_error() {
|
||||
let msg = "unknown variant `errorx`, expected one of \
|
||||
`ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE`";
|
||||
assert_de_tokens_error::<Level>(&[level_token("errorx")], msg);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_level_filter_ser_de() {
|
||||
let cases = [
|
||||
(LevelFilter::Off, [level_filter_token("OFF")]),
|
||||
(LevelFilter::Error, [level_filter_token("ERROR")]),
|
||||
(LevelFilter::Warn, [level_filter_token("WARN")]),
|
||||
(LevelFilter::Info, [level_filter_token("INFO")]),
|
||||
(LevelFilter::Debug, [level_filter_token("DEBUG")]),
|
||||
(LevelFilter::Trace, [level_filter_token("TRACE")]),
|
||||
];
|
||||
|
||||
for &(s, expected) in &cases {
|
||||
assert_tokens(&s, &expected);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_level_filter_case_insensitive() {
|
||||
let cases = [
|
||||
(LevelFilter::Off, [level_filter_token("off")]),
|
||||
(LevelFilter::Error, [level_filter_token("error")]),
|
||||
(LevelFilter::Warn, [level_filter_token("warn")]),
|
||||
(LevelFilter::Info, [level_filter_token("info")]),
|
||||
(LevelFilter::Debug, [level_filter_token("debug")]),
|
||||
(LevelFilter::Trace, [level_filter_token("trace")]),
|
||||
];
|
||||
|
||||
for &(s, expected) in &cases {
|
||||
assert_de_tokens(&s, &expected);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_level_filter_de_error() {
|
||||
let msg = "unknown variant `errorx`, expected one of \
|
||||
`OFF`, `ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE`";
|
||||
assert_de_tokens_error::<LevelFilter>(&[level_filter_token("errorx")], msg);
|
||||
}
|
||||
}
|
|
@ -1,76 +1,66 @@
|
|||
#[macro_use] extern crate log;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
use log::{LogLevel, LogLevelFilter, Log, LogRecord, LogMetadata};
|
||||
use log::MaxLogLevelFilter;
|
||||
use log::{Level, LevelFilter, Log, Record, Metadata};
|
||||
|
||||
#[cfg(feature = "use_std")]
|
||||
use log::set_logger;
|
||||
#[cfg(not(feature = "use_std"))]
|
||||
fn set_logger<M>(make_logger: M) -> Result<(), log::SetLoggerError>
|
||||
where M: FnOnce(MaxLogLevelFilter) -> Box<Log> {
|
||||
unsafe {
|
||||
log::set_logger_raw(|x| std::mem::transmute(make_logger(x)))
|
||||
}
|
||||
#[cfg(feature = "std")]
|
||||
use log::set_boxed_logger;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn set_boxed_logger(logger: Box<Log>) -> Result<(), log::SetLoggerError> {
|
||||
log::set_logger(unsafe { &*Box::into_raw(logger) })
|
||||
}
|
||||
|
||||
struct State {
|
||||
last_log: Mutex<Option<LogLevel>>,
|
||||
filter: MaxLogLevelFilter,
|
||||
last_log: Mutex<Option<Level>>,
|
||||
}
|
||||
|
||||
struct Logger(Arc<State>);
|
||||
|
||||
impl Log for Logger {
|
||||
fn enabled(&self, _: &LogMetadata) -> bool {
|
||||
fn enabled(&self, _: &Metadata) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn log(&self, record: &LogRecord) {
|
||||
fn log(&self, record: &Record) {
|
||||
*self.0.last_log.lock().unwrap() = Some(record.level());
|
||||
}
|
||||
fn flush(&self) {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut a = None;
|
||||
set_logger(|max| {
|
||||
let me = Arc::new(State {
|
||||
last_log: Mutex::new(None),
|
||||
filter: max,
|
||||
});
|
||||
a = Some(me.clone());
|
||||
Box::new(Logger(me))
|
||||
}).unwrap();
|
||||
let a = a.unwrap();
|
||||
let me = Arc::new(State { last_log: Mutex::new(None) });
|
||||
let a = me.clone();
|
||||
set_boxed_logger(Box::new(Logger(me))).unwrap();
|
||||
|
||||
test(&a, LogLevelFilter::Off);
|
||||
test(&a, LogLevelFilter::Error);
|
||||
test(&a, LogLevelFilter::Warn);
|
||||
test(&a, LogLevelFilter::Info);
|
||||
test(&a, LogLevelFilter::Debug);
|
||||
test(&a, LogLevelFilter::Trace);
|
||||
test(&a, LevelFilter::Off);
|
||||
test(&a, LevelFilter::Error);
|
||||
test(&a, LevelFilter::Warn);
|
||||
test(&a, LevelFilter::Info);
|
||||
test(&a, LevelFilter::Debug);
|
||||
test(&a, LevelFilter::Trace);
|
||||
}
|
||||
|
||||
fn test(a: &State, filter: LogLevelFilter) {
|
||||
a.filter.set(filter);
|
||||
fn test(a: &State, filter: LevelFilter) {
|
||||
log::set_max_level(filter);
|
||||
error!("");
|
||||
last(&a, t(LogLevel::Error, filter));
|
||||
last(&a, t(Level::Error, filter));
|
||||
warn!("");
|
||||
last(&a, t(LogLevel::Warn, filter));
|
||||
last(&a, t(Level::Warn, filter));
|
||||
info!("");
|
||||
last(&a, t(LogLevel::Info, filter));
|
||||
last(&a, t(Level::Info, filter));
|
||||
debug!("");
|
||||
last(&a, t(LogLevel::Debug, filter));
|
||||
last(&a, t(Level::Debug, filter));
|
||||
trace!("");
|
||||
last(&a, t(LogLevel::Trace, filter));
|
||||
last(&a, t(Level::Trace, filter));
|
||||
|
||||
fn t(lvl: LogLevel, filter: LogLevelFilter) -> Option<LogLevel> {
|
||||
if lvl <= filter {Some(lvl)} else {None}
|
||||
fn t(lvl: Level, filter: LevelFilter) -> Option<Level> {
|
||||
if lvl <= filter { Some(lvl) } else { None }
|
||||
}
|
||||
}
|
||||
|
||||
fn last(state: &State, expected: Option<LogLevel>) {
|
||||
let mut lvl = state.last_log.lock().unwrap();
|
||||
assert_eq!(*lvl, expected);
|
||||
*lvl = None;
|
||||
fn last(state: &State, expected: Option<Level>) {
|
||||
let lvl = state.last_log.lock().unwrap().take();
|
||||
assert_eq!(lvl, expected);
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ version = "0.32.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clang-sys 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -188,7 +188,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
|
@ -262,7 +262,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "core-text"
|
||||
version = "9.0.0"
|
||||
version = "9.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -445,7 +445,7 @@ name = "encoding_rs"
|
|||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"simd 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -753,6 +753,14 @@ name = "log"
|
|||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "malloc_size_of"
|
||||
version = "0.0.1"
|
||||
|
@ -875,7 +883,7 @@ name = "net2"
|
|||
version = "0.2.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1278,7 +1286,7 @@ dependencies = [
|
|||
"bindgen 0.32.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1562,14 +1570,14 @@ dependencies = [
|
|||
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-text 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-text 9.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwrote 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"freetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plane-split 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1609,7 +1617,7 @@ dependencies = [
|
|||
"euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"foreign-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"thread_profiler 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender 0.57.0",
|
||||
|
@ -1697,7 +1705,7 @@ dependencies = [
|
|||
"checksum byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "652805b7e73fada9d85e9a6682a4abd490cb52d96aeecc12e33a0de34dfd0d23"
|
||||
"checksum bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d828f97b58cc5de3e40c421d0cf2132d6b2da4ee0e11b8632fa838f0f9333ad6"
|
||||
"checksum cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393a5f0088efbe41f9d1fcd062f24e83c278608420e62109feb2c8abee07de7d"
|
||||
"checksum cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c47d456a36ebf0536a6705c83c1cbbcb9255fbc1d905a6ded104f479268a29"
|
||||
"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
|
||||
"checksum clang-sys 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00048189ee171715296dfe3b2fcfd439563c7bfec0d98d3976ce3402d62c8f07"
|
||||
"checksum clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)" = "110d43e343eb29f4f51c1db31beb879d546db27998577e5715270a54bcf41d3f"
|
||||
"checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd"
|
||||
|
@ -1705,7 +1713,7 @@ dependencies = [
|
|||
"checksum core-foundation-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41115a6aa5d3e1e5ef98148373f25971d1fad53818553f216495f9e67e90a624"
|
||||
"checksum core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "716c271e8613ace48344f723b60b900a93150271e5be206212d052bbc0883efa"
|
||||
"checksum core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb0ed45fdc32f9ab426238fba9407dfead7bacd7900c9b4dd3f396f46eafdae3"
|
||||
"checksum core-text 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c737a5c1f112943c961ed270aea64f7d0b01b425d327b040fa32b155646e07f"
|
||||
"checksum core-text 9.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2bd581c37283d0c23311d179aefbb891f2324ee0405da58a26e8594ab76e5748"
|
||||
"checksum cose 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "72fa26cb151d3ae4b70f63d67d0fed57ce04220feafafbae7f503bef7aae590d"
|
||||
"checksum cose-c 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "49726015ab0ca765144fcca61e4a7a543a16b795a777fa53f554da2fffff9a94"
|
||||
"checksum cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8a807ac3ab7a217829c2a3b65732b926b2befe6a35f33b4bf8b503692430f223"
|
||||
|
@ -1750,6 +1758,7 @@ dependencies = [
|
|||
"checksum libloading 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "be99f814beb3e9503a786a592c909692bb6d4fc5a695f6ed7987223acfbd5194"
|
||||
"checksum libudev 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea626d3bdf40a1c5aee3bcd4f40826970cae8d80a8fec934c82a63840094dcfe"
|
||||
"checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b"
|
||||
"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2"
|
||||
"checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376"
|
||||
"checksum memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a"
|
||||
"checksum memmap 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "46f3c7359028b31999287dae4e5047ddfe90a23b7dca2282ce759b491080c99b"
|
||||
|
|
|
@ -127,7 +127,7 @@ version = "0.32.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clang-sys 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -188,7 +188,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
|
@ -262,7 +262,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "core-text"
|
||||
version = "9.0.0"
|
||||
version = "9.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -445,7 +445,7 @@ name = "encoding_rs"
|
|||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"simd 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -751,6 +751,14 @@ name = "log"
|
|||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "malloc_size_of"
|
||||
version = "0.0.1"
|
||||
|
@ -869,7 +877,7 @@ name = "net2"
|
|||
version = "0.2.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1269,7 +1277,7 @@ dependencies = [
|
|||
"bindgen 0.32.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1573,14 +1581,14 @@ dependencies = [
|
|||
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-text 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-text 9.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwrote 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"freetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plane-split 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1620,7 +1628,7 @@ dependencies = [
|
|||
"euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"foreign-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"thread_profiler 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender 0.57.0",
|
||||
|
@ -1699,7 +1707,7 @@ dependencies = [
|
|||
"checksum byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "652805b7e73fada9d85e9a6682a4abd490cb52d96aeecc12e33a0de34dfd0d23"
|
||||
"checksum bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d828f97b58cc5de3e40c421d0cf2132d6b2da4ee0e11b8632fa838f0f9333ad6"
|
||||
"checksum cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393a5f0088efbe41f9d1fcd062f24e83c278608420e62109feb2c8abee07de7d"
|
||||
"checksum cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c47d456a36ebf0536a6705c83c1cbbcb9255fbc1d905a6ded104f479268a29"
|
||||
"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
|
||||
"checksum clang-sys 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00048189ee171715296dfe3b2fcfd439563c7bfec0d98d3976ce3402d62c8f07"
|
||||
"checksum clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)" = "110d43e343eb29f4f51c1db31beb879d546db27998577e5715270a54bcf41d3f"
|
||||
"checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd"
|
||||
|
@ -1707,7 +1715,7 @@ dependencies = [
|
|||
"checksum core-foundation-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41115a6aa5d3e1e5ef98148373f25971d1fad53818553f216495f9e67e90a624"
|
||||
"checksum core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "716c271e8613ace48344f723b60b900a93150271e5be206212d052bbc0883efa"
|
||||
"checksum core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb0ed45fdc32f9ab426238fba9407dfead7bacd7900c9b4dd3f396f46eafdae3"
|
||||
"checksum core-text 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c737a5c1f112943c961ed270aea64f7d0b01b425d327b040fa32b155646e07f"
|
||||
"checksum core-text 9.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2bd581c37283d0c23311d179aefbb891f2324ee0405da58a26e8594ab76e5748"
|
||||
"checksum cose 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "72fa26cb151d3ae4b70f63d67d0fed57ce04220feafafbae7f503bef7aae590d"
|
||||
"checksum cose-c 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "49726015ab0ca765144fcca61e4a7a543a16b795a777fa53f554da2fffff9a94"
|
||||
"checksum cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8a807ac3ab7a217829c2a3b65732b926b2befe6a35f33b4bf8b503692430f223"
|
||||
|
@ -1752,6 +1760,7 @@ dependencies = [
|
|||
"checksum libloading 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "be99f814beb3e9503a786a592c909692bb6d4fc5a695f6ed7987223acfbd5194"
|
||||
"checksum libudev 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea626d3bdf40a1c5aee3bcd4f40826970cae8d80a8fec934c82a63840094dcfe"
|
||||
"checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b"
|
||||
"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2"
|
||||
"checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376"
|
||||
"checksum memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a"
|
||||
"checksum memmap 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "46f3c7359028b31999287dae4e5047ddfe90a23b7dca2282ce759b491080c99b"
|
||||
|
|
Загрузка…
Ссылка в новой задаче