nstree 1.0.0

construct branched 'namespace strings' for nested subcomponents, often for logging
Documentation
//! Module containing [`RawNamespacePathWrapper`]
use core::fmt;

use super::NamespacePath;
use super::RawNamespacePath;

/// Wrapper for [`NamespacePath`]s that uses them to implement [`RawNamespacePath`] using the
/// [`NamespaceComponent`][nsc]s.
///
/// [nsc]: `crate::NamespaceComponent`
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Clone, Copy)]
#[repr(transparent)]
pub struct RawNamespacePathWrapper<NSPath: ?Sized>(pub NSPath);

impl<NSPath> From<NSPath> for RawNamespacePathWrapper<NSPath> {
    #[inline]
    fn from(value: NSPath) -> Self {
        Self(value)
    }
}

impl<T: ?Sized + NamespacePath> RawNamespacePath for RawNamespacePathWrapper<T> {
    #[inline]
    fn raw_components(&self) -> impl IntoIterator<Item = impl fmt::Display> {
        self.0.components()
    }
}

// nstree - nested namespace string-generating abstraction library
// Copyright (C) 2025  Matti <infomorphic-matti at protonmail dot com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
// ------
// SPDX-License-Identifier: GPL-3.0-or-later