1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//! A library to automatically acquire a code location in a rust source code file.
//!
//! # UNMAINTAINED
//!
//! This library is no longer maintained.
//! Although it does work fine, I recommend using [`std::panic::Location`] instead.
//!
//! # Description
//!
//! The library provides the [`code_location!()`] macro.
//! The macro expands to the [`CodeLocation`] struct
//! by combining the standard [`file!()`], [`line!()`] and [`column!()`] macros.
//!
//! [`code_location!()`]: ./macro.code_location.html
//! [`CodeLocation`]: ./struct.CodeLocation.html
//! [`file!()`]: https://doc.rust-lang.org/core/macro.file.html
//! [`line!()`]: https://doc.rust-lang.org/core/macro.line.html
//! [`column!()`]: https://doc.rust-lang.org/core/macro.column.html
//!
//! # Examples
//!
//! ```
//! use code_location::code_location;
//!
//! println!("I am printing from {}", code_location!());
//! assert_eq!(code_location!().to_string(), "src/lib.rs:7:12");
//! ```
//!
//! ```
//! use code_location::{code_location, CodeLocation};
//!
//! let code_location: CodeLocation = code_location!();
//! assert_eq!(code_location.file, "src/lib.rs");
//! assert_eq!(code_location.line, 6);
//! assert_eq!(code_location.column, 35);
//! ```
//!
//! # `serde` serialization and deserialization support
//!
//! [`serde`] support can be enabled with the `"serde"` feature.
//!
//! [`serde`]: https://crates.io/crates/serde
//!
//! # `#![no_std]`
//!
//! `code_location` does not depend on the [standard library].
//!
//! [standard library]: https://doc.rust-lang.org/std/index.html
use fmt;
/// A CodeLocation type to represent a certain point in a source code text file.
///
/// # Examples
///
/// ```
/// use code_location::{code_location, CodeLocation};
///
/// let code_location: CodeLocation = code_location!();
/// assert_eq!(code_location.to_string(), "src/lib.rs:6:35");
/// assert_eq!(code_location.file, "src/lib.rs");
/// assert_eq!(code_location.line, 6);
/// assert_eq!(code_location.column, 35);
/// ```
/// Expands to the [`CodeLocation`] on which it was invoked.
///
/// # Examples
///
/// ```
/// use code_location::code_location;
///
/// println!("I am printing from {}", code_location!());
/// assert_eq!(code_location!().to_string(), "src/lib.rs:7:12");
/// ```
///
/// [`CodeLocation`]: ./struct.CodeLocation.html