Rename function for simplicity

This commit is contained in:
Tobie Morgan Hitchcock 2022-09-19 12:28:41 +01:00
parent 70970862f4
commit d6b544771f
3 changed files with 4 additions and 4 deletions

View file

@ -842,14 +842,14 @@ impl Value {
// ----------------------------------- // -----------------------------------
/// Fetch the record id if there is one /// Fetch the record id if there is one
pub fn rid(self) -> Option<Thing> { pub fn record(self) -> Option<Thing> {
match self { match self {
Value::Object(mut v) => match v.remove("id") { Value::Object(mut v) => match v.remove("id") {
Some(Value::Thing(v)) => Some(v), Some(Value::Thing(v)) => Some(v),
_ => None, _ => None,
}, },
Value::Array(mut v) => match v.len() { Value::Array(mut v) => match v.len() {
1 => v.remove(0).rid(), 1 => v.remove(0).record(),
_ => None, _ => None,
}, },
Value::Thing(v) => Some(v), Value::Thing(v) => Some(v),

View file

@ -123,7 +123,7 @@ pub async fn sc(
// Compute the value with the params // Compute the value with the params
match kvs.compute(val, &sess, vars, opt.strict).await { match kvs.compute(val, &sess, vars, opt.strict).await {
// The signin value succeeded // The signin value succeeded
Ok(val) => match val.rid() { Ok(val) => match val.record() {
// There is a record returned // There is a record returned
Some(rid) => { Some(rid) => {
// Create the authentication key // Create the authentication key

View file

@ -58,7 +58,7 @@ pub async fn sc(
// Compute the value with the params // Compute the value with the params
match kvs.compute(val, &sess, vars, opt.strict).await { match kvs.compute(val, &sess, vars, opt.strict).await {
// The signin value succeeded // The signin value succeeded
Ok(val) => match val.rid() { Ok(val) => match val.record() {
// There is a record returned // There is a record returned
Some(rid) => { Some(rid) => {
// Create the authentication key // Create the authentication key