rename IntoName -> AsName

This commit is contained in:
gnzlbg 2018-11-08 17:56:48 +01:00 committed by gnzlbg
parent 1c5d871828
commit 7fb8e425e5
10 changed files with 14 additions and 14 deletions

View File

@ -1,7 +1,7 @@
//! Arena operations.
use error::Result;
use keys::{Access, IntoName, Mib};
use keys::{Access, AsName, Mib};
use libc::c_uint;
const NARENAS: &[u8] = b"arenas.narenas\0";

View File

@ -1,7 +1,7 @@
//! Background thread operations.
use error::Result;
use keys::{Access, IntoName, Mib};
use keys::{Access, AsName, Mib};
const BACKGROUND_THREAD: &[u8] = b"background_thread\0";

View File

@ -1,6 +1,6 @@
//! Information about the jemalloc compile-time configuration
use error::Result;
use keys::{Access, IntoName, MibStr};
use keys::{Access, AsName, MibStr};
const MALLOC_CONF: &[u8] = b"config.malloc_conf\0";

View File

@ -1,7 +1,7 @@
//! Epoch access.
use error::Result;
use keys::{Access, IntoName, Mib};
use keys::{Access, AsName, Mib};
const EPOCH: &[u8] = b"epoch\0";

View File

@ -1,7 +1,7 @@
//! Key types to index the _MALLCTL NAMESPACE_.
//!
//! The [`Name`] and [`Mib`] types are provided as safe indices into the
//! _MALLCTL NAMESPACE_. These are constructed from slices via the [`IntoName`]
//! _MALLCTL NAMESPACE_. These are constructed from slices via the [`AsName`]
//! and [`IntoMib`] traits. The [`Access`] trait provides provides safe access
//! into the `_MALLCTL NAMESPACE_`.
//!
@ -16,7 +16,7 @@
//! static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
//!
//! fn main() {
//! use jemalloc_ctl::{Access, IntoName, Name, Mib};
//! use jemalloc_ctl::{Access, AsName, Name, Mib};
//! use libc::{c_uint, c_char};
//! let name = b"arenas.nbins\0".name();
//! let nbins: c_uint = name.read().unwrap();
@ -39,12 +39,12 @@ use {fmt, ops, raw};
pub struct Name([u8]);
/// Converts a null-terminated byte-string into a [`Name`].
pub trait IntoName {
pub trait AsName {
/// Converts a null-terminated byte-string into a [`Name`].
fn name(&self) -> &Name;
}
impl IntoName for [u8] {
impl AsName for [u8] {
fn name(&self) -> &Name {
use str;
assert!(
@ -336,7 +336,7 @@ impl Access<&'static str> for Name {
#[cfg(test)]
mod tests {
use super::{Access, IntoName, Mib, MibStr};
use super::{Access, AsName, Mib, MibStr};
#[test]
fn bool_rw() {
let name = b"thread.tcache.enabled\0".name();

View File

@ -104,5 +104,5 @@ mod version;
pub use background_threads::*;
pub use epoch::*;
pub use error::{Error, Result};
pub use keys::{Access, IntoName, Mib, MibStr, Name};
pub use keys::{Access, AsName, Mib, MibStr, Name};
pub use version::*;

View File

@ -2,7 +2,7 @@
//!
//! These settings are controlled by the `MALLOC_CONF` environment variable.
use error::Result;
use keys::{Access, IntoName, Mib, MibStr};
use keys::{Access, AsName, Mib, MibStr};
use libc::c_uint;
const ABORT: &[u8] = b"opt.abort\0";

View File

@ -6,7 +6,7 @@
//! [`Epoch`]: ../struct.Epoch.html
use error::Result;
use keys::{Access, IntoName, Mib};
use keys::{Access, AsName, Mib};
const ALLOCATED: &[u8] = b"stats.allocated\0";

View File

@ -1,7 +1,7 @@
//! Version operations.
use error::Result;
use keys::{Access, IntoName, MibStr};
use keys::{Access, AsName, MibStr};
const VERSION: &[u8] = b"version\0";

View File

@ -2,7 +2,7 @@ extern crate jemalloc_ctl;
extern crate jemallocator;
extern crate libc;
use jemalloc_ctl::{IntoName, Access};
use jemalloc_ctl::{AsName, Access};
use jemallocator::Jemalloc;
use std::alloc::{GlobalAlloc, Layout};