Coder Social home page Coder Social logo

cstr's People

Contributors

chrysn avatar eijebong avatar emilio avatar olivierlemasle avatar upsuper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cstr's Issues

Consider removing the syn dependency

The only thing needing is the function to parse a string literal, do we really need to bring in all of syn for that? Would you consider merging a PR that duplicates syn's own function to parse a string?

Including a file as a CStr

Hi,

I'd like to include a file as a CStr. The include_str! macro lets me include one as a str, but I need it to be null-terminated because it's used to call a specific FFI function that expects a null-terminated string. The cstr! macro fails to compile if include_str! is used as its input, and using a separate static for include string doesn't work because the name is converted to a CStr rather than its contents. Would it be possible for this crate to support this use case?

Supporting no_std

core::ffi::CStr and alloc::ffi::CString have been stabilized for Rust 1.64, which is due to become stable in 9 weeks from now.

Would you consider making this crate no_std? AIU all it'd need to do is to

  • lib.rs needs a #![cfg_attr(not(proc_macro), no_std)]
  • guard content in lib.rs with #[cfg(proc_macro)]. Given that it's almost every line that needs guarding, this might best be done by moving code from src/lib.rs into a module.
  • change the quoted ::std::ffi::CStr to `::core::ffi::CStr``.

I can offer a PR, but it's probably all more a matter of chosen style and how to handle the MSRV increase than of the actual change.

package `cstr v0.2.11` cannot be built because it requires rustc 1.64 or newer, while the currently active rustc version is 1.60.0-nightly

I got error "package cstr v0.2.11 cannot be built because it requires rustc 1.64 or newer, while the currently active rustc version is 1.60.0-nightly" after download today's nightly build
Even though my version is

info: syncing channel updates for 'nightly-x86_64-pc-windows-msvc'
info: checking for self-updates

nightly-x86_64-pc-windows-msvc unchanged - rustc 1.66.0-nightly (4a1467723 2022-09-23)

#[warn(clippy::transmute_ptr_to_ref)]

Using the cstr macro results in the clippy warning #[warn(clippy::transmute_ptr_to_ref)]

warning: transmute from a pointer type (`*const std::ffi::CStr`) to a reference type (`&std::ffi::CStr`)
 --> src/main.rs:3:20
  |
3 | const FOO: &CStr = ::cstr::cstr!("foo");
  |                    ^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(clippy::transmute_ptr_to_ref)]` on by default
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ref
  = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

Is it possible to avoid this warning without disabling the check?

If not, is there a way to disable this lint for invocations of this macro without disabling this lint for my whole project?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.