Preheat oven to 350°F (175°C). Grease a loaf pan.
In a mixing bowl, combine flour, baking soda, baking powder, cinnamon, and salt.
In another bowl, beat together sugar, oil, eggs, and vanilla extract until smooth.
Gradually add the dry ingredients to the wet ingredients, mixing until just combined.
Fold in the grated carrots, grated apple, and walnuts (if using).
Pour the batter into the prepared loaf pan.
Bake for 60 minutes or until a toothpick inserted into the center comes out clean.
Allow the bread to cool in the pan for 10 minutes, then transfer to a wire rack to cool completely.