chore: Clean up useage of unwrap
This commit is contained in:
parent
62834fd690
commit
166cb60d89
|
@ -39,8 +39,7 @@ fn recursive_serialize<'gc>(
|
|||
json_obj: &mut JsonValue,
|
||||
) {
|
||||
for k in &obj.get_keys(avm) {
|
||||
let elem = obj.get(k, avm, action_context).unwrap();
|
||||
|
||||
if let Ok(elem) = obj.get(k, avm, action_context) {
|
||||
match elem {
|
||||
Value::Undefined => {}
|
||||
Value::Null => json_obj[k] = JsonValue::Null,
|
||||
|
@ -51,7 +50,7 @@ fn recursive_serialize<'gc>(
|
|||
// Don't attempt to serialize functions
|
||||
if !o
|
||||
.is_instance_of(avm, action_context, o, avm.prototypes.function)
|
||||
.unwrap()
|
||||
.unwrap_or_default()
|
||||
{
|
||||
let mut sub_data_json = JsonValue::new_object();
|
||||
recursive_serialize(avm, action_context, o, &mut sub_data_json);
|
||||
|
@ -60,6 +59,7 @@ fn recursive_serialize<'gc>(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Deserialize an Object and any children from a JSON object
|
||||
|
@ -293,11 +293,7 @@ pub fn clear<'gc>(
|
|||
this: Object<'gc>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<ReturnValue<'gc>, Error> {
|
||||
let data = this
|
||||
.get("data", avm, action_context)
|
||||
.unwrap()
|
||||
.as_object()
|
||||
.unwrap();
|
||||
let data = this.get("data", avm, action_context)?.as_object()?;
|
||||
|
||||
for k in &data.get_keys(avm) {
|
||||
data.delete(avm, action_context.gc_context, k);
|
||||
|
@ -337,11 +333,7 @@ pub fn flush<'gc>(
|
|||
this: Object<'gc>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<ReturnValue<'gc>, Error> {
|
||||
let data = this
|
||||
.get("data", avm, action_context)
|
||||
.unwrap()
|
||||
.as_object()
|
||||
.unwrap();
|
||||
let data = this.get("data", avm, action_context)?.as_object()?;
|
||||
|
||||
let mut data_json = JsonValue::new_object();
|
||||
recursive_serialize(avm, action_context, data, &mut data_json);
|
||||
|
|
|
@ -16,7 +16,7 @@ impl DiskStorageBackend {
|
|||
.join(scope);
|
||||
|
||||
// Create a base dir if one doesn't exist yet
|
||||
if !&base_path.exists() {
|
||||
if !base_path.exists() {
|
||||
log::info!("Creating storage dir");
|
||||
if let Err(r) = fs::create_dir_all(&base_path) {
|
||||
log::warn!("Unable to create storage dir {}", r);
|
||||
|
|
|
@ -16,7 +16,7 @@ impl StorageBackend for LocalStorageBackend {
|
|||
fn get_string(&self, name: &str) -> Option<String> {
|
||||
self.storage
|
||||
.get(&format!("{}-{}", self.prefix, name))
|
||||
.unwrap()
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn put_string(&mut self, name: &str, value: String) -> bool {
|
||||
|
|
Loading…
Reference in New Issue