Enforcing permalink structure in WordPress

A client site requires a certain permalink structure for some custom plugins to work: WordPress makes it easy.
Enforcing the permalink structure is only half of the work since the other side of it is to flush the rewrite rules (dumping them to the .htaccess file) when setting the new permalink structure.
The function below is a quick code snippet taking care of it:

// make sure the permalink structure is set to /%postname%/
// hook late
add_action('init', 'enforce_permalink_strucure', 999);
function enforce_permalink_strucure() {
    global $wp_rewrite;
    // the target permalink structure
    $structure = '/%postname%/';

    // not this structure?
    if ($wp_rewrite->permalink_structure !== $structure) {