aboutsummaryrefslogtreecommitdiff
path: root/src/ruststring.cpp
blob: 606bfb1504b7c34d5d43a663f34a6106af879430 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "ruststring.h"

namespace newsboat {

extern "C" void rs_cstring_free(char* str);

RustString::RustString(char* ptr)
	: str(ptr)
{
}

RustString::operator std::string()
{
	if (str != nullptr) {
		return std::string(str);
	}
	return std::string();
}

RustString::~RustString()
{
	// This pointer is checked for nullptr on the rust side.
	rs_cstring_free(str);
}

} /* newsboat */