pw_function: Correct typo

Corrects a typo in the Function callable move operation and adds
the missing unit test coverage.

Change-Id: I041ed771df34fba58995156566edaa5a90dc795e
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/83960
Reviewed-by: Alexei Frolov <frolv@google.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
Commit-Queue: Rob Mohr <mohrr@google.com>
diff --git a/pw_function/function_test.cc b/pw_function/function_test.cc
index 541a4c7..8ba01d9 100644
--- a/pw_function/function_test.cc
+++ b/pw_function/function_test.cc
@@ -210,6 +210,13 @@
 #endif  // __clang_analyzer__
 }
 
+TEST(Function, MoveAssign_Callable) {
+  Function<int(int, int)> operation = Multiply;
+  EXPECT_EQ(operation(3, 3), 9);
+  operation = [](int a, int b) -> int { return a + b; };
+  EXPECT_EQ(operation(3, 3), 6);
+}
+
 class MoveTracker {
  public:
   MoveTracker() : move_count_(0) {}
diff --git a/pw_function/public/pw_function/function.h b/pw_function/public/pw_function/function.h
index 0550559..5fd5fc2 100644
--- a/pw_function/public/pw_function/function.h
+++ b/pw_function/public/pw_function/function.h
@@ -88,7 +88,11 @@
   template <typename Callable>
   Function& operator=(Callable callable) {
     holder_.DestructTarget();
-    InitializeTarget(std::move(callable));
+    if (function_internal::IsNull(callable)) {
+      holder_.InitializeNullTarget();
+    } else {
+      holder_.InitializeInlineTarget(std::move(callable));
+    }
     return *this;
   }