For the pastry cream, heat the milk until steaming. Whisk the yolks and sugar until pale, whisk in the flour, then slowly pour in the hot milk while whisking.
Return to the pan and cook over medium heat, whisking constantly, until it boils and thickens, 2 to 3 minutes. Stir in the rum and vanilla, press plastic wrap onto the surface and chill.
For the dough, whisk the flour, baking powder and salt. Beat the butter and sugar until fluffy, beat in the egg, yolks and rum, then mix in the flour. Divide into two pieces, one slightly larger, wrap and chill 1 hour.
Heat the oven to 350°F (180°C) and butter a 9-inch (23 cm) round pan. Roll the larger piece between parchment and line the bottom and sides of the pan.
Spread in the cold pastry cream. Roll the second piece into a 9-inch round, lay it on top and press the edges together to seal. Brush with egg yolk and score a crisscross pattern with a fork.
Bake 45 to 50 minutes, until deep golden. Cool completely in the pan before slicing.