Skip to content

Commit d9851e3

Browse files
committed
gio: use Into<Variant> for SettingsExtManual::set
1 parent 1067617 commit d9851e3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

gio/src/settings.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::prelude::*;
44
use crate::{Settings, SettingsBindFlags};
55
use glib::translate::{from_glib_borrow, from_glib_none, IntoGlib, ToGlibPtr};
66
use glib::variant::FromVariant;
7-
use glib::{BoolError, IsA, ToVariant};
7+
use glib::{BoolError, IsA, Variant};
88

99
#[must_use = "The builder must be built to be used"]
1010
pub struct BindingBuilder<'a> {
@@ -170,7 +170,7 @@ impl<'a> BindingBuilder<'a> {
170170
pub trait SettingsExtManual {
171171
fn get<U: FromVariant>(&self, key: &str) -> U;
172172

173-
fn set<U: ToVariant>(&self, key: &str, value: &U) -> Result<(), BoolError>;
173+
fn set(&self, key: &str, value: impl Into<Variant>) -> Result<(), BoolError>;
174174

175175
#[doc(alias = "g_settings_bind")]
176176
#[doc(alias = "g_settings_bind_with_mapping")]
@@ -194,8 +194,8 @@ impl<O: IsA<Settings>> SettingsExtManual for O {
194194
})
195195
}
196196

197-
fn set<U: ToVariant>(&self, key: &str, value: &U) -> Result<(), BoolError> {
198-
self.set_value(key, &value.to_variant())
197+
fn set(&self, key: &str, value: impl Into<Variant>) -> Result<(), BoolError> {
198+
self.set_value(key, &value.into())
199199
}
200200

201201
fn bind<'a, P: IsA<glib::Object>>(
@@ -268,7 +268,7 @@ mod test {
268268
fn bool_set_get() {
269269
set_env();
270270
let settings = Settings::new("com.github.gtk-rs.test");
271-
settings.set("test-bool", &false).unwrap();
271+
settings.set("test-bool", false).unwrap();
272272
assert!(!settings.get::<bool>("test-bool"));
273273
}
274274

glib/src/variant_dict.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl VariantDict {
130130
/// instance already, you should use the [`insert_value()`](#method.insert_value)
131131
/// method instead.
132132
#[doc(alias = "g_variant_dict_insert_value")]
133-
pub fn insert<T: Into<Variant>>(&self, key: &str, value: T) {
133+
pub fn insert(&self, key: &str, value: impl Into<Variant>) {
134134
unsafe {
135135
ffi::g_variant_dict_insert_value(
136136
self.to_glib_none().0,

0 commit comments

Comments
 (0)