Giter Club home page Giter Club logo

cstrptr-rs's People

Contributors

arcnmx avatar metaworm avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

metaworm

cstrptr-rs's Issues

cstr! does not check for interior nul

Is this unsound or simply erroneous? It at least seems very unlikely to happen by accident.

Fix this by turning it into a proc macro, or if recursive const fn/generics ever become a thing that could work too.

CStr::from_ptr length too short by one

cstrptr-rs/src/cstr.rs

Lines 30 to 33 in bdc51fc

pub unsafe fn from_ptr<'a>(ptr: *const c_char) -> &'a Self {
let len = sys::strlen(ptr);
Self::from_bytes_with_nul_unchecked(core::slice::from_raw_parts(ptr as *const _, len))
}

this should probably be:

Self::from_bytes_with_nul_unchecked(core::slice::from_raw_parts(ptr as *const _, len + 1))

A future where &CStr is fixed

This library intends to paper over the undefined representation of CStr by offering both versions and guaranteeing their performance/storage characteristics. It also re-exports std types when that feature is used. If &CStr is ever fixed to be a single pointer (and thus becomes equivalent to CStrPtr) then the types this crate exports for std need to accommodate that by re-exporting std::ffi::CStr as CStrPtr. It would then offer a custom &CStr pointer implementing the old behaviour.

rustversion would be good to use when the time comes? However, consider that CStrPtr doesn't currently exist due to custom DSTs not being usable, which means that offering &CStrPtr instead of CStrPtr<'_> will require a newer rustc anyway. I suppose a third type name will need to be decided on?

  • &FatCStr
  • &CStr
  • CStrPtr

This naming change could (and maybe should) happen sooner rather than later, then simply do not have &CStr until there's a good way to create it. See also prior art using extern { type c_char; }, and the rustc tracking issue.

std::ffi deviations

Track and fix any API differences for including missing types, functions, etc.

  • std::ffi::NulError (and probably other error types?)
  • lots more!

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.