From 79e4cff8f01a57581a6959864ea7629f8f97975c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D0=BD=D0=B8=D1=81=20=D0=9A=D0=BE=D1=82=D0=BB?= =?UTF-8?q?=D1=8F=D1=80=D0=BE=D0=B2?= Date: Thu, 16 May 2024 23:11:40 +0300 Subject: [PATCH] 1. attempting minor changes to readme.md --- .editorconfig | 14 ++++++++++++++ CODE_OF_CONDUCT.md | 2 +- README.md | 27 +++++++++++++++------------ src/lib.rs | 28 ++++++++++++++-------------- 4 files changed, 44 insertions(+), 27 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..bbee14f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# http://editorconfig.org + +root = true + +[*.rs] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = false +insert_final_newline = false +indent_style = tab +indent_size = 5 +max_line_length = 80 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index a36efc9..257c6f7 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -6,7 +6,7 @@

-## Description: +## Description Our community is dedicated to providing a respectful and inclusive environment for everyone, regardless of gender, age, sexual orientation, disability, physical appearance, body size, race, nationality, or religion. diff --git a/README.md b/README.md index b84a6a5..f5c6d1b 100644 --- a/README.md +++ b/README.md @@ -21,18 +21,17 @@ clulab - - [![CI](https://github.com/clucompany/cluCStr/actions/workflows/CI.yml/badge.svg?event=push)](https://github.com/clucompany/cluCStr/actions/workflows/CI.yml) + [![CI](https://github.com/clucompany/cluCStr/actions/workflows/CI.yml/badge.svg?event=push)](https://github.com/clucompany/cluCStr/actions/workflows/CI.yml) -## Note: +## Note You can use `c"wow"` since Rust 1.77.0 instead of `cstr!("wow")` from this crate. This new feature provides more concise code and faster compilation. If you are using an older Rust API (like 1.66), this crate will still be relevant for some time. -## Usage: +## Usage Add this to your Cargo.toml: @@ -42,20 +41,22 @@ clucstr = "1.2.0" ``` and this to your source code: + ```rust use cluCStr::cstr; use core::ffi::CStr; ``` -## Example: +## Example + ```rust use cluCStr::cstr; use core::ffi::CStr; fn main() { - let cstr = cstr!(b"How are you?"); - - assert_eq!(cstr.to_bytes_with_nul(), b"How are you?\0"); + let cstr = cstr!(b"How are you?"); + + assert_eq!(cstr.to_bytes_with_nul(), b"How are you?\0"); } ``` @@ -63,7 +64,8 @@ fn main() { See all -## License: +## License + This project has a single license (LICENSE-APACHE-2.0).
@@ -71,16 +73,17 @@ This project has a single license (LICENSE-APACHE-2.0). uproject  Copyright (c) 2019-2024 #UlinProject - +  (Denis Kotlyarov).


-### Apache License: +### Apache License +
apache2 - +  Licensed under the Apache License, Version 2.0.



diff --git a/src/lib.rs b/src/lib.rs index b6949f5..b05d8ee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,11 +23,11 @@ /*! Safe and efficient creation of "CStr" with zero-byte checking and support for concatenating multiple values. -## Note: +## Note You can use `c"wow"` since Rust 1.77.0 instead of `cstr!("wow")` from this crate. This new feature provides more concise code and faster compilation. If you are using an older Rust API (like 1.66), this crate will still be relevant for some time. -## Example: +## Example ```rust use cluCStr::cstr; use core::ffi::CStr; @@ -54,7 +54,7 @@ use quote::quote; use proc_macro::TokenStream; use proc_macro2::{TokenTree as TokenTree2, Literal, Span}; -/// Returns tokens that generate a compilation error with the given message +/// Returns tokens that generate a compilation error with the given message /// in the specified source code range. #[inline] fn __make_pm_compile_error(span: Span, message: &str) -> TokenStream { @@ -64,7 +64,7 @@ fn __make_pm_compile_error(span: Span, message: &str) -> TokenStream { }) } -/// The macro creates a tree with a single compile_error macro and with +/// The macro creates a tree with a single compile_error macro and with /// the corrected span and error message. macro_rules! pm_compile_error { ($span: expr, $e: expr) => {{ @@ -72,7 +72,7 @@ macro_rules! pm_compile_error { }}; } -/// Checks for null bytes in the data being processed and aborts with an error +/// Checks for null bytes in the data being processed and aborts with an error /// message if one is detected. macro_rules! thiserr_nullbyte { [ @@ -86,13 +86,13 @@ macro_rules! thiserr_nullbyte { }}; } -/// A marker that determines the presence of a zero byte (error) in the +/// A marker that determines the presence of a zero byte (error) in the /// formation of CSTR. struct ErrDetectedNullByte; -/// The SafeCStrBuilder struct provides an interface for safely creating C-compatible -/// strings (strings that are terminated by a null byte). -/// It guarantees that all data is valid (does not contain any null bytes), +/// The SafeCStrBuilder struct provides an interface for safely creating C-compatible +/// strings (strings that are terminated by a null byte). +/// It guarantees that all data is valid (does not contain any null bytes), /// except for the trailing null byte. struct SafeCStrBuilder(Vec); @@ -132,8 +132,8 @@ impl SafeCStrBuilder { self.0.is_empty() } - /// Returns a fragment of CSTR bytes. - /// + /// Returns a fragment of CSTR bytes. + /// /// (always without trailing null byte) #[inline] #[allow(dead_code)] @@ -151,7 +151,7 @@ impl SafeCStrBuilder { Some(..) => Err(ErrDetectedNullByte), None => { self.0.extend_from_slice(arr); - + Ok(()) } } @@ -159,7 +159,7 @@ impl SafeCStrBuilder { /// Converts the CSTR into a COW slice of bytes. /// - /// !Note that if the string is empty, no allocation occurs and a single + /// !Note that if the string is empty, no allocation occurs and a single /// generic empty CSTR is returned. pub fn into(mut self) -> Cow<'static, [u8]> { match self.is_empty() { @@ -171,7 +171,7 @@ impl SafeCStrBuilder { }, false => { self.0.push(0); - + self.0.into() } }