Skip to content

Commit a592126

Browse files
authored
replace crate with \$crate for all macros (#113)
Fixes #112
1 parent b618d75 commit a592126

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/_macros.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ macro_rules! enable_tskit_traits {
1717
macro_rules! handle_tsk_return_value {
1818
($code: expr) => {{
1919
if $code < 0 {
20-
return Err(crate::error::TskitError::ErrorCode { code: $code });
20+
return Err($crate::error::TskitError::ErrorCode { code: $code });
2121
}
2222
Ok($code)
2323
}};
2424
($code: expr, $return_value: expr) => {{
2525
if $code < 0 {
26-
return Err(crate::error::TskitError::ErrorCode { code: $code });
26+
return Err($crate::error::TskitError::ErrorCode { code: $code });
2727
}
2828
Ok($return_value)
2929
}};
@@ -32,7 +32,7 @@ macro_rules! handle_tsk_return_value {
3232
macro_rules! panic_on_tskit_error {
3333
($code: expr) => {
3434
if $code < 0 {
35-
let c_str = unsafe { std::ffi::CStr::from_ptr(crate::bindings::tsk_strerror($code)) };
35+
let c_str = unsafe { std::ffi::CStr::from_ptr($crate::bindings::tsk_strerror($code)) };
3636
let str_slice: &str = c_str.to_str().unwrap();
3737
let message: String = str_slice.to_owned();
3838
panic!("{}", message);
@@ -42,8 +42,8 @@ macro_rules! panic_on_tskit_error {
4242

4343
macro_rules! unsafe_tsk_column_access {
4444
($i: expr, $lo: expr, $hi: expr, $array: expr) => {{
45-
if $i < $lo || ($i as crate::tsk_size_t) >= $hi {
46-
Err(crate::error::TskitError::IndexError {})
45+
if $i < $lo || ($i as $crate::tsk_size_t) >= $hi {
46+
Err($crate::error::TskitError::IndexError {})
4747
} else {
4848
Ok(unsafe { *$array.offset($i as isize) })
4949
}
@@ -118,7 +118,7 @@ macro_rules! drop_for_tskit_type {
118118

119119
macro_rules! tskit_type_access {
120120
($name: ident, $ll_name: ty) => {
121-
impl crate::TskitTypeAccess<$ll_name> for $name {
121+
impl $crate::TskitTypeAccess<$ll_name> for $name {
122122
fn as_ptr(&self) -> *const $ll_name {
123123
&*self.inner
124124
}
@@ -132,7 +132,7 @@ macro_rules! tskit_type_access {
132132

133133
macro_rules! build_tskit_type {
134134
($name: ident, $ll_name: ty, $drop: ident) => {
135-
impl crate::ffi::WrapTskitType<$ll_name> for $name {
135+
impl $crate::ffi::WrapTskitType<$ll_name> for $name {
136136
fn wrap() -> Self {
137137
let temp: std::mem::MaybeUninit<$ll_name> = std::mem::MaybeUninit::uninit();
138138
$name {
@@ -147,7 +147,7 @@ macro_rules! build_tskit_type {
147147

148148
macro_rules! metadata_to_vector {
149149
($self: expr, $row: expr) => {
150-
crate::metadata::char_column_to_vector(
150+
$crate::metadata::char_column_to_vector(
151151
$self.table_.metadata,
152152
$self.table_.metadata_offset,
153153
$row,
@@ -161,7 +161,7 @@ macro_rules! decode_metadata_row {
161161
($T: ty, $buffer: expr) => {
162162
match $buffer {
163163
None => Ok(None),
164-
Some(v) => Ok(Some(<$T as crate::metadata::MetadataRoundtrip>::decode(
164+
Some(v) => Ok(Some(<$T as $crate::metadata::MetadataRoundtrip>::decode(
165165
&v,
166166
)?)),
167167
}
@@ -182,7 +182,7 @@ macro_rules! process_state_input {
182182
match $state {
183183
Some(x) => (
184184
x.as_ptr() as *const libc::c_char,
185-
x.len() as crate::bindings::tsk_size_t,
185+
x.len() as $crate::bindings::tsk_size_t,
186186
$state,
187187
),
188188
None => (std::ptr::null(), 0, $state),
@@ -192,7 +192,7 @@ macro_rules! process_state_input {
192192

193193
macro_rules! err_if_not_tracking_samples {
194194
($flags: expr, $rv: expr) => {
195-
match $flags.contains(crate::TreeFlags::SAMPLE_LISTS) {
195+
match $flags.contains($crate::TreeFlags::SAMPLE_LISTS) {
196196
false => Err(TskitError::NotTrackingSamples),
197197
true => Ok($rv),
198198
}
@@ -219,7 +219,7 @@ macro_rules! table_row_access {
219219
macro_rules! iterator_for_nodeiterator {
220220
($ty: ty) => {
221221
impl Iterator for $ty {
222-
type Item = crate::tsk_id_t;
222+
type Item = $crate::tsk_id_t;
223223
fn next(&mut self) -> Option<Self::Item> {
224224
self.next_node();
225225
self.current_node()

0 commit comments

Comments
 (0)