One man's trash is another man's — or worm's — treasure. Research from Stanford shows that darkling beetle larvae, commonly called mealworms, will happily eat a diet of polystyrene (better known by its trade name, styrofoam), providing a possible method for disposing of this notoriously durable and pervasive plastic waste.

Related: Millions of Tons! Scientists Tally Up Plastic Pollution in Oceans

Wei-Min Wu and his colleagues at the university's Department of Civil and Environmental Engineering raised a hundred mealworms from birth strictly on styrofoam, which the creatures can digest thanks to a type of bacteria in their gut. Each worm ate about a few dozen milligrams every day, converting about half to carbon dioxide and leaving half behind as non-toxic waste.

Mealworms feed on styrofoam during the experiment. Yu Yang / Stanford

Amazingly, the worms seem to suffer no ill effects from eating plastic all day — they were as healthy as a control group that ate bran. The team is making sure, however, by watching for issues that could be delayed, only appear after multiple generations or after being consumed by yet another creature.

Understanding how bacteria process a plastic thought to be practically indestructible, let alone edible, may lead to a way of disposing safely of the millions of tons of non-recyclable plastic thrown away every year. The work comes on the heels of the discovery that the larva of another insect, the Indian mealmoth, can degrade polyethylene, another problematic plastic.

"Our findings have opened a new door to solve the global plastic pollution problem," said Wu in Stanford's news release. The studies are detailed in the journal Environmental Science and Technology.