Skip to content

Commit

Permalink
feat(ada_owned_string/ToString): add
Browse files Browse the repository at this point in the history
Makes it possible to convert ada_owned_string to ToString
  • Loading branch information
pratikpc committed May 20, 2024
1 parent f9979bd commit 21ac2ee
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ffi.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#![allow(non_camel_case_types)]
use core::ffi::{c_char, c_uint};

#[cfg(feature = "std")]
extern crate std;

#[repr(C)]
pub struct ada_url {
_unused: [u8; 0],
Expand Down Expand Up @@ -38,6 +41,13 @@ impl AsRef<str> for ada_owned_string {
}
}

#[cfg(feature = "std")]
impl ToString for ada_owned_string {
fn to_string(&self) -> std::string::String {
self.as_ref().to_owned()
}
}

impl Drop for ada_owned_string {
fn drop(&mut self) {
// @note This is needed because ada_free_owned_string accepts by value
Expand Down

0 comments on commit 21ac2ee

Please sign in to comment.