{"id":16930207,"url":"https://github.com/tmccombs/ptrplus","last_synced_at":"2025-04-11T18:32:01.016Z","repository":{"id":14223434,"uuid":"76140523","full_name":"tmccombs/ptrplus","owner":"tmccombs","description":"Extra functionality for pointers in rust","archived":false,"fork":false,"pushed_at":"2022-11-22T06:59:05.000Z","size":22,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T14:21:37.786Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.rs/ptrplus/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmccombs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-10T22:12:47.000Z","updated_at":"2022-04-29T06:03:57.000Z","dependencies_parsed_at":"2023-01-13T17:50:39.191Z","dependency_job_id":null,"html_url":"https://github.com/tmccombs/ptrplus","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccombs%2Fptrplus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccombs%2Fptrplus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccombs%2Fptrplus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccombs%2Fptrplus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmccombs","download_url":"https://codeload.github.com/tmccombs/ptrplus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248458602,"owners_count":21107112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T20:41:09.032Z","updated_at":"2025-04-11T18:32:00.993Z","avatar_url":"https://github.com/tmccombs.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build status](https://github.com/tmccombs/ptrplus/workflows/Build/badge.svg)](https://github.com/tmccombs/ptrplus/actions?query=workflow%3ABuild)\n[![Crates.io](https://img.shields.io/crates/v/ptrplus.svg)](https://crates.io/crates/ptrplus)\n[![Crates.io](https://img.shields.io/crates/d/ptrplus.svg)](https://crates.io/crates/ptrplus)\n\n# ptrplus\n\nPtrplus is a library that adds additional functionality around raw pointers.\n\n## Conversions\n\nPtrplus provides traits to convert between raw pointers and safer Rust pointer types. `AsPtr`, `IntoRaw`,\nand `FromRaw` provide common traits for types that implement `as_ptr`, `into_raw`, and `from_raw` respectively.\nOf note, these traits also have implementations for `Option` to handle nullable raw pointers.\n\n## Examples\n\n```rust\nuse ptrplus::AsPtr;\n\nlet x: \u0026u32 = \u00265;\nlet y: *const u32 = x.as_ptr();\nunsafe {\n    assert_eq!(*y, 5);\n}\n```\n\n```rust\nuse ptrplus::AsPtr;\n\nlet x = 5;\nlet o1: Option\u003c\u0026u32\u003e = None;\nlet o2: Option\u003c\u0026u32\u003e = Some(\u0026x);\n\nassert!(o1.as_ptr().is_null());\nassert!(!o2.as_ptr().is_null());\nunsafe {\n    assert_eq!(*o2.as_ptr(), 5);\n}\n```\n\n```rust\nuse ptrplus::IntoRaw;\n\nlet x: Box\u003cu32\u003e = Box::new(5);\nlet y: *mut u32 = IntoRaw::into_raw(x);\nunsafe {\n  assert_eq!(*y, 5);\n  *y = 6;\n  Box::from_raw(y);\n}\n\n```\n\n```rust\nuse ptrplus::{FromRaw, IntoRaw};\n\nlet o1: Option\u003cBox\u003cu32\u003e\u003e = None;\nlet o2: Option\u003cBox\u003cu32\u003e\u003e = Some(Box::new(5));\n\nlet p1: *mut u32 = o1.into_raw();\nlet p2: *mut u32 = o2.into_raw();\n\nassert!(p1.is_null());\nassert!(!p2.is_null());\nunsafe {\n    assert_eq!(*p2, 5);\n    let o1: Option\u003cBox\u003cu32\u003e\u003e = Option::from_raw(p1);\n    let o2: Option\u003cBox\u003cu32\u003e\u003e = Option::from_raw(p2);\n    assert!(o1.is_none());\n    assert!(!o2.is_none());\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmccombs%2Fptrplus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmccombs%2Fptrplus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmccombs%2Fptrplus/lists"}