In a medium-sized saucepan bring the milk (minus 1/4 cup (60 ml)) and the coconut milk just to boiling (bubbles form around the outside edge of saucepan.)
Then in a heatproof bowl, whisk the egg yolks with the remaining 1/4 cup (60 ml) of milk. In another small bowl whisk the sugar with the cornstarch (corn flour) and salt.
Add the sugar mixture to the egg yolks and whisk until smooth. When the milk just starts to boil, remove from heat and, whisking constantly to prevent the eggs from cooking, slowly add the milk to the egg mixture. (If you do get a few pieces of cooked egg, pour through a strainer.)
Then pour the mixture into a medium saucepan and cook over medium heat until boiling, whisking constantly. Continue to whisk for another 30 - 60 seconds or just until it becomes thick. (The filling starts out quite thin but will thicken as it cooks. When it comes to a boil it may be a little lumpy. Stir vigorously and the lumps with smooth out.)
Remove from heat and immediately whisk in the butter, vanilla extract and rum (if using). Gently stir in 1 cup (240 ml) of the toasted coconut. Pour into the baked and cooled pastry crust, cover with plastic wrap, and refrigerate for 3-4 hours (or overnight) or until firm.