mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 04:35:36 +08:00
Fabric: Support for optionals in convertRawProp and debugStringConvertibleItem templates
Summary: We have to have automatic treatment for `optional` types. So, if we can process type `T` we can also automatically process `optional<T>.` Support for optional allows us to not introduce new types (with embedded special "undefined" value) or pollute existing pure types (with special "undefined" value). (A lot of examples of those types can be found in AttributedString module.) Reviewed By: fkgozali Differential Revision: D7958249 fbshipit-source-id: 21af526a17dd0329e1262020cab8ecb902316654
This commit is contained in:
committed by
Facebook Github Bot
parent
03fb77cc95
commit
7048c9134a
@@ -28,6 +28,14 @@ inline SharedDebugStringConvertible debugStringConvertibleItem(std::string name,
|
||||
return std::make_shared<DebugStringConvertibleItem>(name, toString(value));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline SharedDebugStringConvertible debugStringConvertibleItem(std::string name, folly::Optional<T> value, T defaultValue = {}) {
|
||||
if (!value.has_value()) {
|
||||
return nullptr;
|
||||
}
|
||||
return debugStringConvertibleItem(name, value.value_or(defaultValue), defaultValue);
|
||||
}
|
||||
|
||||
SharedDebugStringConvertibleList operator+(const SharedDebugStringConvertibleList &lhs, const SharedDebugStringConvertibleList &rhs);
|
||||
SharedDebugStringConvertible debugStringConvertibleItem(std::string name, DebugStringConvertible value, std::string defaultValue = "");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user