chiark / gitweb /
Append \n when we write out a JSON file.
authorSimon Tatham <anakin@pobox.com>
Sat, 6 Jan 2024 13:10:38 +0000 (13:10 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 6 Jan 2024 13:36:10 +0000 (13:36 +0000)
I just happened to notice that serde_json::to_string_pretty makes the
result pretty in every way except this one.

src/login.rs

index 867d8020ca56b1c220df61fa03f66ccd436be84c..8a63d0362371cc07f2e0760b1d4afd29b928b8e7 100644 (file)
@@ -212,7 +212,9 @@ pub fn login(cfgloc: &ConfigLocation, instance_url: &str,
         user_token: user_token.access_token,
     };
 
-    cfgloc.create_file("auth", &serde_json::to_string_pretty(&auth).unwrap())?;
+    let mut json = serde_json::to_string_pretty(&auth).unwrap();
+    json.push('\n');
+    cfgloc.create_file("auth", &json)?;
 
     Ok(())
 }