Skip to content

Commit

Permalink
Using Self for enum pattern matching and improved a bit the code an…
Browse files Browse the repository at this point in the history
…d documentation
  • Loading branch information
Razican committed Apr 11, 2020
1 parent 5f19656 commit aa47eda
Show file tree
Hide file tree
Showing 13 changed files with 514 additions and 488 deletions.
12 changes: 6 additions & 6 deletions boa/src/builtins/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl ObjectInternalMethods for Object {
impl Object {
/// Return a new ObjectData struct, with `kind` set to Ordinary
pub fn default() -> Self {
let mut object = Object {
let mut object = Self {
kind: ObjectKind::Ordinary,
internal_slots: Box::new(HashMap::new()),
properties: Box::new(HashMap::new()),
Expand All @@ -289,8 +289,8 @@ impl Object {
///
/// https://tc39.es/ecma262/#sec-objectcreate
// TODO: proto should be a &Value here
pub fn create(proto: Value) -> Object {
let mut obj = Object::default();
pub fn create(proto: Value) -> Self {
let mut obj = Self::default();
obj.internal_slots
.insert(INSTANCE_PROTOTYPE.to_string(), proto);
obj.internal_slots
Expand All @@ -312,7 +312,7 @@ impl Object {

/// Return a new Boolean object whose [[BooleanData]] internal slot is set to argument.
fn from_boolean(argument: &Value) -> Self {
let mut obj = Object {
let mut obj = Self {
kind: ObjectKind::Boolean,
internal_slots: Box::new(HashMap::new()),
properties: Box::new(HashMap::new()),
Expand All @@ -327,7 +327,7 @@ impl Object {

/// Return a new Number object whose [[NumberData]] internal slot is set to argument.
fn from_number(argument: &Value) -> Self {
let mut obj = Object {
let mut obj = Self {
kind: ObjectKind::Number,
internal_slots: Box::new(HashMap::new()),
properties: Box::new(HashMap::new()),
Expand All @@ -342,7 +342,7 @@ impl Object {

/// Return a new String object whose [[StringData]] internal slot is set to argument.
fn from_string(argument: &Value) -> Self {
let mut obj = Object {
let mut obj = Self {
kind: ObjectKind::String,
internal_slots: Box::new(HashMap::new()),
properties: Box::new(HashMap::new()),
Expand Down
Loading

0 comments on commit aa47eda

Please sign in to comment.